On Tuesday, 16 September 2014 at 14:53:52 UTC, bearophile wrote:
Among the CppCon 2014 slide packs there is this nice one:

"Types Don't Know #", by Howard Hinnant:

https://github.com/CppCon/CppCon2014/tree/master/Presentations/Types%20Don%27t%20Know%20%23%20-%20Howard%20Hinnant%20-%20CppCon%202014

It shows a nice idea to perform transitive hashing in a flexible and efficient way. Perhaps the idea can be used in D too. It suggests the introduction of a hashAppend standard method.

Yes, I've never understood why std::hash was designed the way it
is.  Or why allowing the user to supply a seed value seems to be
unusual for publicly available hash routines (which is basically
what Howard has proposed).  rt.util.hash.hashOf accepts a seed
value, and any hash routine we made publicly callable should as
well.  Not to do so is really pretty useless.

I guess this also has implications for composite types in D.  If
I have a class that references other classes, I might want to do
the same basic thing.  In which case, calling Object.toHash isn't
sufficient as it fails in the same manner.  I suppose we really
need to extend toHash to accept an optional seed value as well.

Reply via email to