ProtoObject and comparison for equality and ordering

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed May 15 00:51:18 UTC 2019


On 5/14/19 1:32 AM, Adam D. Ruppe wrote:
> On Wednesday, 15 May 2019 at 00:19:05 UTC, Andrei Alexandrescu wrote:
>> I repeat myself: this won't work.
>>
>> Recall that a < b is lowered into a.opCmp(b) < 0. So we have a 
>> comparison against the literal 0.
> 
> We could just as well change the definition of the lowering to
> 
> a.opCmp(b) == ComparisonResult.lessThan
> 
> 
> I understand the generated instructions would be slightly different and 
> that might be relevant, but if we're talking about changing things, no 
> need to arbitrarily draw the line like that.

The DIP does not set out to change the semantics of opCmp.

At a larger level I'm fascinated by our community's penchant to work on 
small problems. Comparisons in D work just fine, thank you very much, 
yet here we are calmly setting up the trench warfare. Must be an enum, 
must change opCmp, must do anything and everything as long as it's 
different from what we have. And we carefully pick up the least generous 
topics, too. In our search for water, we aren't happy until we find the 
driest patch of sand to drill into, while carefully avoiding the 
generous marshes.


More information about the Digitalmars-d mailing list