[swift-evolution] Smart KeyPaths
svabox at gmail.com
Fri Mar 17 13:27:45 CDT 2017
On 17.03.2017 20:04, Michael LeHew via swift-evolution wrote:
> Hi friendly swift-evolution folks,
> The Foundation and Swift team would like for you to consider the following
> Many thanks,
> Smart KeyPaths: Better Key-Value Coding for Swift
Just my 2 cents. FWIW, I feel like the proposed syntax is VERY confusing.
Person.friends.name - like access to static property. T.method can't
have subscript for it and then some field. So, I believe such key paths
deserve its own syntax.
luke[path] - very close to access the subscript of instance. In compare to
T.method, we can call result of T.method(i.e. let m = T.method; m()), just
like the T.method itself(foo.method()). But here we are calling some kind
of subscript instead of access property by "path".
There is no some 'special' marker for me that saying "hey, there is
references to properties used" from the first look.
Probably we can consider another separators, like
Person[friends.name] // single brackets for type
luke[[path]] // double brackets for instance
Person at friends.name
luke at path
or other with help of community.
More information about the swift-evolution