[swift-evolution] [Draft] Hasher & HashVisitable
Joe Groff
jgroff at apple.com
Tue Mar 14 10:41:43 CDT 2017
> On Mar 13, 2017, at 8:38 AM, Vincent Esche via swift-evolution <swift-evolution at swift.org> wrote:
>
> Source compatibility
>
> Making use of "extending protocols to conform to protocols":
>
> extension Hashable: HashVisitable
> {
>
> func hash<H: Hasher>(_ hasher: inout
> H) {
>
> self.hashValue.hash(&
> hasher)
> }
> }
We're unlikely to add this feature soon. It seems reasonable to me to instead have `HashVisitable` refine `Hashable` and provide a default implementation of `hashValue` using a default hasher. I think we still want `Hashable` to be the currency protocol most APIs work with for performance in unspecialized code, since we could inline the visitation and hasher implementation together inside the specialized `hashValue` witness.
-Joe
More information about the swift-evolution
mailing list