opCmp / opEquals do not actually support partial orders
Dominikus Dittes Scherkl
dominikus.scherkl at continental-corporation.com
Thu Jul 19 10:14:34 UTC 2018
On Wednesday, 18 July 2018 at 17:30:21 UTC, Jonathan M Davis
wrote:
> On Tuesday, July 17, 2018 21:18:12 John Colvin via
> Digitalmars-d wrote:
>> Just do what std.typecons.Proxy does and return float.nan for
>> the incomparable case.
>
> Since when is that legal? I thought that it was required for
> opCmp to return int. Certainly, the spec implies that it has to
> be int. The fact that the compiler allows it seems like a bug,
> though if Phobos is doing it, it wouldn't surprise me if Walter
> would choose to update the spec rather than fixing the compiler.
It always worked with float as returntype (at least since I'm
using D
- about 2.40 or so?), and it was necessary for the (unfortunately
deprecated) special operators <>, !<>, <>=, !<>=, ...
would really pissing me off if someone deemed this excellent
feature
beeing a bug and removed it. The OP already found out that some
valuable mathematical concepts doesn't work with only 3 values for
opCmp. The 4th value is essencial.
More information about the Digitalmars-d
mailing list