Fixing opEquals and opCmp

Simen Kjærås via Digitalmars-d digitalmars-d at puremagic.com
Sat May 13 16:29:38 PDT 2017


On Saturday, 13 May 2017 at 14:17:24 UTC, H. S. Teoh wrote:
> Andrei specifically stated before that opCmp may model a 
> partial order, i.e., returning 0 may indicate "not comparable" 
> rather than "equal".  And this is why opEquals is necessary: to 
> distinguish between "not comparable" and "equal".

As others have pointed out, that seems wrong. However, returning 
float.nan does make a bit of sense. Given a nan return value, a 
<= b and a >= b will both be false.


More information about the Digitalmars-d mailing list