[swift-evolution] [Review] SE-0131: Add AnyHashable to the standard library

Pyry Jahkola pyry.jahkola at iki.fi
Mon Jul 25 15:34:07 CDT 2016


> On 24 Jul 2016, at 01:26, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
> 
> Hello Swift community,
> 
> The review of "SE-0131: Add AnyHashable to the standard library" begins now and runs through July 25.  This proposal is a bit unusual, since it is a late additive proposal.  The reason we need to do something here is as a critical part of "SE-0116: Import Objective-C id as Swift Any type”, enabling importing untyped NSDictionary's and NSSet’s properly.  The core team considers this already conceptually approved for Swift 3 as part of SE-0116, but would greatly appreciate feedback on the details of the proposed design.
> 
> The proposal is available here:
> 
> 	https://github.com/apple/swift-evolution/blob/master/proposals/0131-anyhashable.md
> 
> 	* What is your evaluation of the proposal?

+1, this is a nice addition, and useful at times.

There's one very obscure gotcha <https://swiftlang.ng.bluemix.net/#/repl/c1ddd24113169ab82df118660c8e0de6ea24e48d32997c327638a88dc686e91f> with AnyHashable that subclass instances of a Hashable base class should be cast to the base type before wrapping into AnyHashable, otherwise such wrapped values may break the equivalence law of symmetry (`a == b` iff `b == a`).

But now that most of Foundation's class clusters are bridged into value types, that problem is unlikely to occur to anyone anymore.

> 	* Is the problem being addressed significant enough to warrant a change to Swift?

So and so.

> 	* Does this proposal fit well with the feel and direction of Swift?

Yes. Maybe it will also help us gain more experience when designing real existential types.

> 	* If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?

A bit of a hack compared to real existentials. But a good one.

> 	* How much effort did you put into your review? A glance, a quick reading, or an in-depth study?

Quick reading.

— Pyry

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


More information about the swift-evolution mailing list