On Friday, October 07, 2016 12:04:09 Mark via Digitalmars-d wrote: > I'm going over the Object class methods and I have a few concerns > about the opEquals method. > > First, what should be the default implementation of opEquals? The > specification (see > https://dlang.org/spec/operatoroverloading.html#eqcmp) reads: > > "If opEquals is not specified, the compiler provides a default > version that does member-wise comparison" > > But this doesn't appear to be the case (at least with dmd). So I > went and checked the module in > https://github.com/dlang/druntime/blob/master/src/object.d. It > implements opEquals by comparing references (obj1 is obj2), not > by member-wise comparison. > > Wouldn't member-wise comparison be a more intuitive default?
The current behavior is what it's always been and actually is consistent with what Java and C# do. Not to mention, we're actually planning to eventually remove opEquals from Object. https://issues.dlang.org/show_bug.cgi?id=9769 Speaking of which, this PR to templatize the free function version of opEquals needs some folks to review it and merge it: https://github.com/dlang/druntime/pull/1439 It's just been languishing even though it's theoretically ready to go and has been for months. - Jonathan M Davis