WAT: opCmp and opEquals woes

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Fri Jul 25 13:12:17 PDT 2014


On Fri, Jul 25, 2014 at 07:21:04PM +0000, via Digitalmars-d wrote:
> On Friday, 25 July 2014 at 13:44:54 UTC, H. S. Teoh via Digitalmars-d wrote:
> >Exactly!! I don't understand why people keep bringing up non-linear
> >partial orderings -- those only apply in a *minority* of cases!
> 
> Well, if <, <= etc are only to be used where you have a "natural"
> total order then I guess you are right, but then opCmp should be
> limited to those types.

No it doesn't have to be. If you want it to work with non-linear orders,
just define your own opEquals. We're talking about the *default*
behaviour here. Linear orders should be default because they are what
people want (and expect) in the majority of cases. Nobody said anything
about making it *impossible* to define non-linear orderings.


T

-- 
It only takes one twig to burn down a forest.


More information about the Digitalmars-d mailing list