[swift-evolution] [Draft] Hasher & HashVisitable

David Waite david at alkaline-solutions.com
Tue Mar 14 18:45:32 CDT 2017


It would be possible for a Hasher to return varying types, but then people might want the interface to support cryptographic hashing as well as variable length hashes (for things like HAMT)

-DW

> On Mar 14, 2017, at 4:56 PM, Greg Parker via swift-evolution <swift-evolution at swift.org> wrote:
> 
> 
>> On Mar 14, 2017, at 12:01 PM, David Sweeris via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>> 
>> Are we committed to having `hashValue` always be an `Int`, or could it be an associated type like  `(Int, Int, Int, Int)`? Seems like especially for something like a BigNum type or an Array, there might simple not be a reasonably efficient way to uniquely-ish represent 1024 bits with just 64 bits.
>> 
>> (This kinda feels like one of those questions where the answer starts out with a variation on “you’re missing the point”)
> 
> This would lead to an implementation nightmare for hashing containers. Consider what the implementation of Dictionary<Any, String> would look like if any of its keys could have incompatible hash outputs.
> 
> 
> -- 
> Greg Parker     gparker at apple.com <mailto:gparker at apple.com>     Runtime Wrangler
> 
> 
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170314/f92808aa/attachment.html>


More information about the swift-evolution mailing list