[swift-evolution] [Draft] Hasher & HashVisitable
Joe Groff
jgroff at apple.com
Tue Mar 14 10:34:24 CDT 2017
> On Mar 13, 2017, at 10:54 AM, Sean Heber via swift-evolution <swift-evolution at swift.org> wrote:
>
> I’m dumb when it comes to proper hashing, but it’s such a tediously common thing in my experience to need to add Hashable to some kind of a struct so I can stash it in a set or use it as a dictionary key. Is there really no way to make this all more automatic? I have to be honest - this proposal seems *harder* to understand than the way it works now. Of course the easiest would be if the language could just do this “good enough" for me using reflection or whatever and if I really did run into a problem where I wanted to do this myself, I could override something.
>
> Perfect is the enemy of good.
The compiler totally ought to derive reasonable default Equatable and Hashable implementations for you. That would allow the standard library to do the right thing without burdening most users with the need to sweat the details.
-Joe
More information about the swift-evolution
mailing list