[swift-evolution] [Review] SE-0161: Smart KeyPaths: Better Key-Value Coding for Swift

Matthew Johnson matthew at anandabits.com
Sat Apr 1 10:21:38 CDT 2017


> 
> What is your evaluation of the proposal?
+1.  This is a fantastic proposal!  I have been looking forward to the ability to access unbound properties ever since Swift was first released.  I am very happy to see it coming to the language.  The design of this feature is even better than I had been hoping for!

That said, I do feel like the syntax changes in the revised draft were a step backwards on two fronts.  The new syntax is inconsistent with that of the syntax used for unbound methods.  IMO all unbound members should be available using the same syntax.  Second, the new syntax is (IMO) too cumbersome, especially in the shorthand case where a type context is known.  

This feature can be leveraged to build libraries with DSL-like interfaces of various kinds.  The more cumbersome syntax significantly reduces the elegance of these designs.  This is unfortunate.  As I have mentioned before, I think we should consider using the `#` separator to indicate the start of the unbound portion of a member chain.  This aligns with the convention of # indicating compiler magic and is very lightweight.

While I am not fully satisfied with the current syntax I would not want to see that stop the proposal from being accepted.  It is a huge step forward and new syntactic sugar could be added in the future without breaking old code.


> Is the problem being addressed significant enough to warrant a change to Swift?
Yes, this is a huge improvement!

> Does this proposal fit well with the feel and direction of Swift?
Very much.

> If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?
It is better than other languages I have used where unbound property access was limited to direct properties, not entire chains or properties and subscripts.

> How much effort did you put into your review? A glance, a quick reading, or an in-depth study?
In depth study.  And I am already writing code that will use Smart KeyPaths as soon as they are implemented.

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


More information about the swift-evolution mailing list