[swift-evolution] Smart KeyPaths
Ricardo Parada
rparada at mac.com
Wed Mar 22 16:02:25 CDT 2017
By the way, I am okay with the syntax in the proposal too. I'm just brainstorming so that we can look at all the options. I am guessing the authors (David Smith, Michael LeHew and Joe Groff) probably went through this process already and settled with the simpler notation. :-)
> On Mar 22, 2017, at 4:51 PM, Ricardo Parada via swift-evolution <swift-evolution at swift.org> wrote:
>
> Yes, I was about to ask the same.
>
> It seems like all the sigil characters are taken. This is one of the reasons why I did not object to the non-sigil notation originally proposed despite the ambiguity with static properties and instance properties with the same name. But using a sigil seems like it can unify method references and key path references.
>
> Is the single quote taken? For example:
>
> let path = 'Bag.things[0].name
> bag[path]
> bag['Bag.things[0].name]
> bag['.things[0].name]
> bag.things[0]['.name]
> bag.things[0]['Thing.name]
>
> And the examples on the proposal would become:
>
> 'Person.friends[0].name
> luke['.friends[0].name]
> luke.friends[0]['.name]
>
> If we were to put it between root and the path then it would look like this:
>
> let path = Bag'things[0].name
> bag[path]
> bag[Bag'things[0].name]
> bag['things[0].name]
> bag.things[0]['name]
> bag.things[0][Thing'name]
>
>
> Right now the compiler tells me that it found an "unterminated string literal".
>
> When I add the closing single quote then it tells me "single-quoted string literal found, use '"' instead"
>
>
>
>
>> On Mar 22, 2017, at 3:16 PM, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>
>>> On Mar 22, 2017, at 9:00 AM, Vladimir.S via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>
>>> bag[#path]
>>
>> What do these do?
>>
>> bag[#file]
>> bag[#line]
>> bag[#function]
>> // etc.
>>
>> --
>> Brent Royal-Gordon
>> Architechies
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> _______________________________________________
> 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/20170322/30812aa0/attachment.html>
More information about the swift-evolution
mailing list