digitalmars.D - Flexible and efficient recursive hashing
- bearophile (8/8) Sep 16 2014 Among the CppCon 2014 slide packs there is this nice one:
- Szymon Gatner (4/13) Sep 17 2014 Funny thing is that as soon as you have to combine hashes in C++
- H. S. Teoh via Digitalmars-d (8/17) Sep 17 2014 [...]
- Sean Kelly (12/19) Sep 17 2014 Yes, I've never understood why std::hash was designed the way it
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
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, bearophileFunny 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
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
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