ProtoObject and comparison for equality and ordering

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed May 15 00:15:38 UTC 2019


On 5/14/19 10:21 PM, Mike Franklin wrote:
> On Tuesday, 14 May 2019 at 20:36:08 UTC, Eduard Staniloiu wrote:
> 
>> Should `opCmp` return a float?
>>
>> The reason: when we attempt to compare two types that aren't 
>> comparable (an unordered relationship) we can return float.NaN. Thus 
>> we can differentiate between a valid -1, 0, 1 and an invalid float.NaN 
>> comparison.
> 
> Thinking about this a little more, why would the compiler even allow 
> comparing two types that aren't comparable?  Shouldn't that be a 
> compiler error?

Their dynamic types may be comparable.



More information about the Digitalmars-d mailing list