WAT: opCmp and opEquals woes

via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 26 03:43:07 PDT 2014


On Saturday, 26 July 2014 at 09:48:55 UTC, Andrei Alexandrescu 
wrote:
> On 7/26/14, 2:19 AM, "Marc Schütz" <schuetzm at gmx.net>" wrote:
>> Yes, that's why it's possible to provide opEquals in addition 
>> to opCmp.

Not quite, opCmp would then have to throw if opCmp(a,b) is 
incomparable. Conflating incomparable and equal values as 0 is a 
bad idea when sorting. That means incomparable values are 
sprinkled randomly over the sort.

> Case-insensitive ordering is a simple example.

That doesn't sound right. "<=" is defined for all possible pairs. 
Case insensitive ordering satisfies the totality requirement: (a 
<= b or b <= a), for all strings a and b?


More information about the Digitalmars-d mailing list