Fixing opEquals and opCmp

Stanislav Blinov via Digitalmars-d digitalmars-d at puremagic.com
Sat May 13 08:05:02 PDT 2017


On Saturday, 13 May 2017 at 15:00:27 UTC, Fool wrote:
> 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".
>
> Well, that's unsound.
>
> Example: 'is (proper) subset of'
>
> Given the sets a:= {1} and b:= {2}, we have
>
>  a is not a proper subset of b;
>  b is not a proper subset of a;
>
> If a.opCmp(b) returns 0 in this situation then, due to the 
> rewrite
>
>  a <= b   a.opCmp(b) <= 0,
>
> we have:
>
>  a is a subset of b

In this case, typeof(a) should not be the same as typeof(b), 
which can be handled correctly by opCmp.


More information about the Digitalmars-d mailing list