[phobos] Issue with opEquals(Object, Object)

Andrei Alexandrescu andrei at erdani.com
Mon Apr 26 13:25:12 PDT 2010


That sounds a bit too complicated. opEquals is a simplified collision 
engine. If you want to define a full-fledged one, it may be simpler to 
go the named functions route.

Andrei

On 04/23/2010 09:21 PM, Steve Schveighoffer wrote:
> More thoughts...
>
> What if an object wants say it's able to compare itself to another object, but that other object doesn't know how to compare itself to the first one.  Should this return not equal?  It might be that the first object was written after the second, or one object is part of a wrapper library.
>
> To fix this, we would almost need a canCompare(Object o) function which would return one of several values:
>
> DEFER -- defer to other object, I have no way to compare myself to it.
> REQUIRED -- I can compare myself to the other object, but I want to ensure my routine is always called.
> OPTIONAL -- I can compare myself to the other object, but I'm ok if you choose to only call the other object's routine.
> NO -- Return false without doing any comparison, these objects cannot be equal.
>
> The default would be DEFER.
>
> -Steve
>
>
>
> _______________________________________________
> phobos mailing list
> phobos at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/phobos


More information about the phobos mailing list