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

John Colvin via Digitalmars-d digitalmars-d at puremagic.com
Tue Jan 12 17:39:26 PST 2016


On Wednesday, 13 January 2016 at 00:31:48 UTC, Andrei 
Alexandrescu wrote:
> On 01/12/2016 06:52 PM, John Colvin wrote:
>> On Tuesday, 12 January 2016 at 22:28:13 UTC, Andrei 
>> Alexandrescu wrote:
>>> On 01/12/2016 03:56 PM, John Colvin wrote:
>>>> Please consider the second design I proposed?
>>>
>>> I don't think it solves a large problem. -- Andrei
>>
>> Ok. Would you consider any solution, or is that a "leave it 
>> broken"?
>
> I'd leave it to a named function. Using the built-in comparison 
> for exotic orderings is bound to confuse users. BTW not sure 
> you know, but D used to have a number of floating point 
> operators like !<>=. Even those didn't help. -- Andrei

I would completely agree, except that we have builtin types that 
don't obey this rule. I'd be all in favour of sticking with total 
orders, but it does make it hard (impossible?) to make a proper 
drop-in replacement for the builtin floating point numbers 
(including wrappers, e.g. std.typecons.Typedef can't handle nans 
correctly) or to properly handle comparisons between custom types 
and builtin floating points (as mentioned by tsbockman).

I am all for keeping it simple here, but I still think there's a 
problem.


More information about the Digitalmars-d mailing list