Last year, Howard Hinnant proposed a composable hash algorithm framework for C++ that I was impressed with.
His proposal is here: http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2014/n3980.html
A live presentation is here: https://www.youtube.com/watch?v=Njjp_MJsgt8 <https://www.youtube.com/watch?v=Njjp_MJsgt8>
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.
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.