== operator

Jonathan Marler via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 3 17:30:10 PST 2015


I've recently looked at how the '==' operator works with classes. 
  I was disappointed to find that 'a == b' always gets rewritten 
to:

.object.opEquals(a, b);

The reason for my disappointment is that this results in 
unnecessary overhead. I would think that the compiler would first 
try to rewrite the '==' operator using a type-specific opEquals 
method, then fall back on the generic version if one did not 
exist.  Is there a reason for this?


More information about the Digitalmars-d mailing list