hashOf()

Márcio Martins via Digitalmars-d digitalmars-d at puremagic.com
Wed Nov 2 09:14:23 PDT 2016


There are 2 hashOf() definitions, one in object.d and one in 
core.internal.hash.d

If you include core.internal.hash, you cannot call hashOf() 
anymore, because it conflicts with the implicit import in 
object.d, this is annoying in itself...
The bigger issue though, is that they have different semantics:

import core.internal.hash : hashOfInt = hashOf;

void main() {
     string moo = "moo";
     assert(moo.hashOfInt == moo.idup.hashOfInt); // ok - hashes 
moo.ptr[0..moo.length]
     assert(moo.hashOf == moo.idup.hashOf); // fail - hashes 
&moo[0..moo.sizeof]
}

Did anyone else fall into this trap?


More information about the Digitalmars-d mailing list