InternetAddress comparison fail

Jonathan Marler via Digitalmars-d digitalmars-d at puremagic.com
Sat Jan 3 16:16:01 PST 2015


On Saturday, 3 January 2015 at 23:46:01 UTC, Martin Nowak wrote:
> On Saturday, 3 January 2015 at 16:33:56 UTC, Jonathan Marler 
> wrote:
>> So what is the right way to compare the contents of 2 classes?
>>  I thought it was to implement an opEquals method.  It pains 
>> me to see people using the toAddrString function to compare 
>> Address classes:(  This is so inefficient and unnecessary.
>
> Sure, someone should make a pull and implement opEquals for the 
> Address classes, maybe also opHash.

I've made a pull request 
(https://github.com/D-Programming-Language/phobos/pull/2839#discussion_r22435562). 
  I haven't used opEquals that much in D so I'm not super familiar 
with it.  It does concern me a little though.  I'm wondering why 
the type specific opEquals isn't called first before the generic 
opEquals(Object) method when using the '==' operator.  According 
to the documentation, (a == b), where a and b are classes, is 
rewritten as ".object.opEquals(a, b)".  I'm just wondering why 
there has to be overhead when using the '==' operator.  Instead, 
the type specific opEquals operator should be called, then if it 
does not exist, then the generic ".object.opEquals" method should 
be used.  Why isn't it done this way?


More information about the Digitalmars-d mailing list