WAT: opCmp and opEquals woes

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 25 01:54:02 PDT 2014


On 7/25/2014 1:27 AM, Jacob Carlborg wrote:
> On 25/07/14 08:50, Walter Bright wrote:
>
>> Yes, that's why it's hard to see that it would break existing code,
>> unless that existing code had a bug in it that was worked around in some
>> peculiar way.
>
> If the type was only used as an AA key and never checked for equivalent then it
> worked correctly when opCmp was used for AA keys.
>
> Also, adding an opEqual to call opCmp == 0 will make it work for equivalent as
> well, even though it's never used. And it will fix the breaking change with AA
> keys.

The thing is, either this suffers from == behaving differently than AAs, or 
you've made opEquals superfluous by defining it to be opCmp==0. The latter is a 
mistake, as Andrei has pointed out, as opCmp may not have a concept of equality, 
and opEquals may not have a concept of ordering.

I.e. it's not just about AAs.



More information about the Digitalmars-d mailing list