Fixing opEquals and opCmp

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Sat May 13 07:17:24 PDT 2017


On Sat, May 13, 2017 at 01:21:12PM +0000, Fool via Digitalmars-d wrote:
> On Saturday, 13 May 2017 at 12:53:33 UTC, Nicholas Wilson wrote:
[...]
> > 3) you can do that already. w.r.t sort you pass a predicate
> > (defaulting to "less") for which ordering is assumed to exist, if it
> > doesn't then you get a partition according to that predicate.
> 
> Another misunderstanding. Currently, there is no means to express that
> 'less' models a partial order vs. a linear order.

Wrong.  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".


T

-- 
A computer doesn't mind if its programs are put to purposes that don't match their names. -- D. Knuth


More information about the Digitalmars-d mailing list