hashOf()

Márcio Martins via Digitalmars-d digitalmars-d at puremagic.com
Thu Nov 3 06:16:23 PDT 2016


On Thursday, 3 November 2016 at 13:11:41 UTC, Steven 
Schveighoffer wrote:
> On 11/2/16 12:14 PM, Márcio Martins wrote:
>> [...]
>
> You are not the only one:
>
> https://forum.dlang.org/post/nv85ou$gi5$1@digitalmars.com
>
> Note, I wholly disagree with the idea that hashOf(arr) hashes 
> the pointer and length elements. I get why it does, and get 
> what the charter of hashOf is. But nobody expects it.
>
> IMO, hashOf should fail to compile on types that contain 
> pointers, including arrays. In fact, I'm thinking hashOf 
> shouldn't even be available in object. It's completely 
> inconsistent with all other forms of hashing a type (which use 
> typeinfo, opHash, etc.). It's too low-level, and should be 
> accessible only via an import.
>
> -Steve

That's what I'd expect as well. The hashOf() in 
core.internal.hash is useful, and it works intuitively, IMO, so 
if one is implicitly imported it should be that one...


More information about the Digitalmars-d mailing list