opCmp, [partial/total/pre]orders, custom floating point types etc.

Dominikus Dittes Scherkl via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 23:30:00 PST 2016


On Wednesday, 13 January 2016 at 02:12:36 UTC, tsbockman wrote:
> On Wednesday, 13 January 2016 at 01:43:21 UTC, John Colvin 
> wrote:
>>> I am all for keeping it simple here, but I still think 
>>> there's a problem.
>>
>> https://issues.dlang.org/show_bug.cgi?id=15561
>
> That's a good point.

Interesting. I often use partially-ordered objects in my code, 
and therefore define opCmp to return float, making use of the NaN 
value. But then I also define opEquals to return false for (NaN 
== NaN), and my custom types work as intended.
In fact, the existance of the special floatingpoint operators 
like !<> (and beeing able to overload them) was one of the main 
reasons for me, to start using D. For me it's a mayor issue if 
those operators don't work correct.

I know they are deprecated, but I don't know why. As was pointed 
out they are necessary if you want to implement something 
partially ordered. That not everybody needs this is no valid 
reason to deprecate it.

I hated to be told I should not define opCmp to return float 
instead of int, as was also propagated by the "learning D" book.
If this is the common state of the art, I will drop D and start 
using my own fork the moment they are not supported anymore.


More information about the Digitalmars-d mailing list