A fresh look at comparisons

Yigal Chripun yigal100 at gmail.com
Tue Apr 15 15:50:07 PDT 2008


After reading the documentation for operator overloading I think there
is a much simpler solution to this problem. have a look at the
definition of Object in phobos - it contains opEquals and opCmp and
that's it. No other opSomthing are defined there.
 
So basically, I propose just removing those two operators from Object.

if opEquals is not defined for the specific object than the compiler
should default to identity comparison (as if you've used "is"),
otherwise it'll use the defined method and return bool.

if opCmp is not defined than the compiler will issue an error for trying
to compare incomparable types.  otherwise, let it work the same as today.

-- Yigal



More information about the Digitalmars-d mailing list