Last year, Howard Hinnant proposed a composable hash algorithm framework for C++ that I was impressed with.
His proposal is here: Types Don't Know #
A live presentation is here: CppCon 2014: Howard Hinnant "Types Don't Know #" - YouTube <CppCon 2014: Howard Hinnant "Types Don't Know #" - YouTube;
A type with multiple fields you inevitably want to do a hash_combine but this pollutes the hashing algorithm. It turns out that (nearly) all hashing algorithms can be abstracted into 3 phases: initialization, digestion and finalization. It might be cool if Swift Hashable adopted this pluggable architecture.
1. Easily adopt Hashable
2. Easily change and compare hash algorithms based on performance / security needs
3. Make good hash implementations trivial for users.
Wondering if anyone has thought about this already / if it would be worthwhile pursuing more.
Best wishes,
Ray
PS: I have always thought that it is a bummer that compound types such as tuples can’t conform to protocols and therefore be Hashable.