ProtoObject and comparison for equality and ordering
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Wed May 15 01:02:49 UTC 2019
On 5/14/19 1:57 AM, Seb wrote:
> Well, you already plan to change the compiler, so changing it to create
> a different opCmp lowering when it sees this special enum wouldn't be so
> hard, no?
The DIP's charter does not include modifying opCmp.
> i.e. if both opCmps return a special CompEnum, do sth. like this:
>
> a < b => a.opCmp(b) == lowerCmp
> ...
>
>
> There's no price to pay this way.
Well there would be in some instances. People often implement
comparisons as a - b currently, where a and b are int expressions. That
would need to become...
return a < b ? lowerCmp : a > b ? upperCmp : equivCmp;
That's definitely liable to be worse for those cases.
Overall: I dream of a D landscape whereby this is enough of a problem to
deserve discussion, a DIP, review, and implementation. As things are
there are sufficient things to discuss and improve in D to make this
exchange ironic.
More information about the Digitalmars-d
mailing list