WAT: opCmp and opEquals woes

Brad Roberts via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 23 14:45:22 PDT 2014


On 7/23/2014 2:36 PM, Andrei Alexandrescu via Digitalmars-d wrote:
> On 7/23/14, 12:04 PM, H. S. Teoh via Digitalmars-d wrote:
>> If autogenerating opEquals to be opCmp()==0 is a no-go, then I'd much
>> rather say it should be a compile error if the user defines opCmp but
>> not opEquals.
>
> No. There is this notion of partial ordering that makes objects not 
> smaller and not greater than others, yet not equal. -- Andrei

Right, but in that case just define both.  It's not the dominant case so 
shouldn't define the default behavior.  Or if you truly have a case of 
comparable but no possibility of equal, just @disable opEqual (or define 
and throw, or assert, or...).


More information about the Digitalmars-d mailing list