recursive equal, and firstDifference functions
Dan
dbdavidson at yahoo.com
Tue Mar 19 20:16:15 PDT 2013
On Wednesday, 20 March 2013 at 02:54:23 UTC, Jonathan M Davis
wrote:
> On Wednesday, March 20, 2013 03:48:38 Dan wrote:
>> On Wednesday, 20 March 2013 at 02:03:31 UTC, Jonathan M Davis
>>
>> wrote:
>> > We already get this. That's what == does by default. It's
>> > just
>> > that it uses ==
>> > on each member, so if == doesn't work for a particular member
>> > variable and the
>> > semantics you want for == on the type it's in, you need to
>> > override opEquals.
>>
>> Really?
>>
>> string is one most people would like == to just work for. This
>> writes true then false. This certainly takes getting used to.
>> It
>> alone is a good reason for the mixins and potentially a
>> non-member instancesDeepEqual.
>>
>> import std.stdio;
>> struct S {
>> string s;
>> }
>> void main() {
>> writeln("foo" == "foo".idup);
>> writeln(S("foo") == S("foo".idup));
>> }
>
> That's a bug:
>
> http://d.puremagic.com/issues/show_bug.cgi?id=3789
>
From Feb 2010. Maybe by now it is so understood how it works that
at some point fixing it could be a problem. For some the language
is better defined by how the compiler treats your code than what
is listed in bugzilla. Even in looking through the history of
that bug I could not find any definitive - some say its a bug,
others say its not. You refer to TDPL which is a good source but
if it is not viewed as a bug by Walter...
More information about the Digitalmars-d-learn
mailing list