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

Tony Allevato tony.allevato at gmail.com
Thu Apr 6 11:35:47 CDT 2017

On Thu, Apr 6, 2017 at 9:31 AM Sean Heber via swift-evolution <
swift-evolution at swift.org> wrote:

> > On Apr 6, 2017, at 11:19 AM, Douglas Gregor <dgregor at apple.com> wrote:
> >
> >>
> >> On Apr 6, 2017, at 8:13 AM, Ricardo Parada via swift-evolution <
> swift-evolution at swift.org> wrote:
> >>
> >> I agree, there's an analogy between strings and key paths, and in that
> regards the single quote would make sense.  I would not complain.
> >
> > The only analogy between strings and key-paths is that the existing
> Cocoa APIs for key-paths use strings. That’s not an analogy to hang
> language syntax on, because it’s relevance will fade quickly.
> Why would it fade quickly? Do we expect the concept of keypaths to go away
> over time? If so, why are we even designing a syntax for keypaths?

I think the naming of this proposal as "keypaths" has caused some confusion
in this regard. Try to consider them without the Objective-C history and
look at Swift as a language in its own right: does it make sense for a
chain of strongly-typed unbound property references—AND unbound method
references, because they will use this syntax as well—to be represented as
something akin to a string literal? IMO, the answer to that is no.

Nobody is suggesting that the concept of keypaths will go away—the proposal
is evidence of that and in fact it shows that they want to improve them
beyond the string-based versions that were required by Objective-C because
of its dynamism and string-based-selector syntax.

It would be a mistake to tie down Swift's superior implementation based on
tortured analogies to Objective-C.

> > The core team discussed single quotes, and decided that we want to save
> them for something in the string/character realm.
> Are they to be saved for something specific or is this just because a lot
> of languages use single quotes for character literals? Why is this
> association any more sacred than an association with Cocoa string keypaths?
> l8r
> Sean
> _______________________________________________
> 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/20170406/29268843/attachment.html>

More information about the swift-evolution mailing list