WAT: opCmp and opEquals woes

via Digitalmars-d digitalmars-d at puremagic.com
Sat Jul 26 00:42:02 PDT 2014


On Saturday, 26 July 2014 at 06:50:11 UTC, Manu via Digitalmars-d 
wrote:
> It's okay, I hate it too.
> But I equally can't abide == meaning something different than 
> <, <=, etc.
> That's insane.

Yes, it is unsound to use opCmp for types that aren't totally 
ordered:

http://en.wikipedia.org/wiki/Partially_ordered_set

«In general two elements x and y of a partial order may stand in 
any of four mutually exclusive relationships to each other: 
either x < y, or x = y, or x > y, or x and y are incomparable 
(none of the other three). A totally ordered set is one that 
rules out this fourth possibility: all pairs of elements are 
comparable and we then say that trichotomy holds. The natural 
numbers, the integers, the rationals, and the reals are all 
totally ordered by their algebraic (signed) magnitude whereas the 
complex numbers are not.»

> Like I said, I'm just absolutely astonished that people think 
> the situation
> in your OP is okay, especially when the solution is so obvious.

Right, when you only have 3 states, you should require total 
order.



More information about the Digitalmars-d mailing list