Overloading relational operators separately; thoughts?

Walter Bright via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 28 12:52:05 PDT 2016


On 9/28/2016 2:48 AM, Matthias Bentrup wrote:
> In Mathematics the comparison operators are also commonly used for semi orders,
> which cannot be implemented by opCmp, because opCmp has no way to indicate that
> two values are incomparable.
>
> Interestingly the floating point types are semi ordered (due to NaNs), and for
> those D has some (non-overridable and deprecated) operators like !<, which would
> be easily extendable to any semi order, whereas the suggested replacement (i.e.
> test for NaNs manually) works only on floats.

I'm aware of the limitation, and a fair amount of thought was given on it, but 
the solution used generally for unordered is to test for it separately, and 
people seem happy with it.

The !<, etc., operators have been an utter failure (not a failure technically, 
but people found them hopelessly confusing and would not use them).



More information about the Digitalmars-d mailing list