ProtoObject and comparison for equality and ordering

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Wed May 15 01:16:56 UTC 2019


On 5/14/19 2:03 AM, Adam D. Ruppe wrote:
> So, going back to where the int/float/enum tangent started....
> 
> On Tuesday, 14 May 2019 at 20:36:08 UTC, Eduard Staniloiu wrote:
>> interface Ordered(T)
>> {
>>     int opCmp(scope const T rhs);
>> }
>>
>> Since we are here, I want to raise another question:
>> Should `opCmp` return a float?
> 
> 
> We'd then have two interfaces: Ordered!T, which returns the int, and 
> then PartiallyOrdered!T that can return the float. You pick which one 
> works best for your particular class.

Wait, if we go with the statically-checked solution all interfaces are 
no longer necessary. Or maybe I'm misunderstanding?


More information about the Digitalmars-d mailing list