[phobos] Issue with opEquals(Object, Object)

Steve Schveighoffer schveiguy at yahoo.com
Fri Apr 23 19:21:03 PDT 2010


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


      


More information about the phobos mailing list