Oh, ok.

First of all the docs appear somewhat misleading.  I thought that function was an example on how to overload it.  That could be clarified a little.

Second of all, isn't that inefficient?  And  if you wanted to be able to compare to another type you don't control?  I think it would make more sense to have it pick the best match much like other overloads.

On Feb 22, 2012 9:05 PM, "H. S. Teoh" <hsteoh@quickfur.ath.cx> wrote:
On Wed, Feb 22, 2012 at 08:51:50PM -0500, Kevin wrote:
> I have the following code which gives the same result on ldc2 and
> dmd.  If I compare two objects of different classes I always get
> false even though the comparator is called.
[...]
> The key thing to notice is that opEquals() gets called both times.
> Any ideas about what is happening?

It's because when A and B are different types, the compiler translates
A==B to:

       A.opEquals(B) && B.opEquals(A)

Both parties need to agree before they are considered equal.


T

--
Shin: (n.) A device for finding furniture in the dark.