[swift-evolution] Smart KeyPaths

Brent Royal-Gordon brent at architechies.com
Fri Mar 17 15:58:24 CDT 2017


> On Mar 17, 2017, at 10:04 AM, Michael LeHew via swift-evolution <swift-evolution at swift.org> wrote:
> Introduction
> We propose a family of concrete Key Path types that represent uninvoked references to properties that can be composed to form paths through many values and directly get/set their underlying values.
> 
I don't know how to express the level of "Yes" I feel in response to this proposal without using language that's inappropriate on a public mailing list.

A few questions:

How do key paths interact with Optionals? Can you form a key path to `Person.bestFriend.name`, and is that the syntax, or is it `Person.bestFriend?.name`?

Foundation key paths have a sometimes-useful property where, if they traverse a collection, the result becomes a collection of the ending type. Is a similar feature planned for smart key paths—perhaps something like `Person.friends[].name`?

Given that Swift has a syntax called #keyPath which is unrelated to these "key paths", have you considered using a different name to avoid confusion? Maybe "property paths" or "accessor paths"?

-- 
Brent Royal-Gordon
Architechies

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


More information about the swift-evolution mailing list