Overloading relational operators separately; thoughts?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Wed Sep 28 06:05:13 PDT 2016


On 28.09.2016 11:48, Matthias Bentrup wrote:
> On Wednesday, 28 September 2016 at 04:02:59 UTC, Walter Bright wrote:
>> The limitations are deliberate based on the idea that comparison
>> operators need to be consistent and predictable, and should have a
>> close relationship to the mathematical meaning of the operators.
>
> 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.
> ...

Yes it does.

float opCmp(S rhs){
     return float.nan; // incomparable
}



More information about the Digitalmars-d mailing list