www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Flexible and efficient recursive hashing

reply "bearophile" <bearophileHUGS lycos.com> writes:
Among the CppCon 2014 slide packs there is this nice one:



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.

Bye,
bearophile
Sep 16 2014
next sibling parent "Szymon Gatner" <noemail gmail.com> writes:
On Tuesday, 16 September 2014 at 14:53:52 UTC, bearophile wrote:
 Among the CppCon 2014 slide packs there is this nice one:



 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.

 Bye,
 bearophile
Funny thing is that as soon as you have to combine hashes in C++ atm you realize that current way is broken and the way HH proposes is kindof obvious correct design.
Sep 17 2014
prev sibling next sibling parent "H. S. Teoh via Digitalmars-d" <digitalmars-d puremagic.com> writes:
On Tue, Sep 16, 2014 at 02:53:51PM +0000, bearophile via Digitalmars-d wrote:
 Among the CppCon 2014 slide packs there is this nice one:
 

 
 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.
[...] This is all the more reason to make rt.util.hash.hashOf available to user code. It already supports chaining, which would be the equivalent of hashAppend. T -- The computer is only a tool. Unfortunately, so is the user. -- Armaphine, K5
Sep 17 2014
prev sibling parent "Sean Kelly" <sean invisibleduck.org> writes:
On Tuesday, 16 September 2014 at 14:53:52 UTC, bearophile wrote:
 Among the CppCon 2014 slide packs there is this nice one:



 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.
Sep 17 2014