<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I love the proposal and it is great to see this feature being considered. This provides a great foundation for future functionality. I too find the syntax confusing. The syntax is elegant and does not introduce any extra keywords, but accessing key paths is an advanced “meta” feature and does not have to be this straightforward. I would prefer less potential ambiguity at the expense of a little extra verbosity.</div><div class=""><br class=""></div><div class="">I suggest that the all keypaths be grouped under a `keypaths` pseudo-root path. This eliminates potential ambiguity with other language constructs and is easier for humans ( and as an added benefit, the compiler) to parse, reducing potential errors and clearer error diagnostics for name collisions and misspellings. Compiler reasoning and error messages are difficult enough deal with today. The use of a unique root for all keypaths will also greatly simplify searching for uses and code maintenance.</div><div class=""><br class=""></div><div class="">Many of the advanced language features that have been proposed for Swift add elegance and power to the language, but they have a cost in comprehensibility especially to beginners. The use of `keypaths` greatly improves the discoverability of this feature.</div><div class=""><br class=""></div><div class="">Another potential benefit of introducing a keyword-like construct now could simplifies the task of adding more metadata with other pseudo-root paths like `classKeypaths` and others as the language evolves.</div><div class=""><br class=""></div><div class="">Here is your example, rewritten with `keypaths` highlighted as a keyword. It does not add any additional nesting or operators, but clearly identifies the construct as something different and provides a simple term to search for in documentation.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; color: rgb(0, 119, 170);" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">struct</span><span style="font-kerning: none; color: #000000; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">Person</span><span style="font-kerning: none; color: #000000; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">{</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">var</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> name</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">:</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">String</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">var</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> friends</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">:</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">Person</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">]</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">var</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> bestFriend</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">:</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">Person</span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">?</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; color: rgb(153, 153, 153);" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">}</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; min-height: 17px;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">var</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> han </span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">=</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #dd4a68; text-shadow: 0.0px 1.0px 0.0px #000000" class="">Person</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">(</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">name</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">:</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">"Han Solo"</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">,</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> friends</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">:</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[])</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">var</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> luke </span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">=</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #dd4a68; text-shadow: 0.0px 1.0px 0.0px #000000" class="">Person</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">(</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">name</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">:</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">"Luke Skywalker"</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">,</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> friends</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">:</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">han</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">])</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; min-height: 17px;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">let</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> firstFriendsNameKeyPath </span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">=</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">Person</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">.</span><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">keypaths.</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">friends</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; color: #990055; text-shadow: 0.0px 1.0px 0.0px #000000" class="">0</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">].</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">name</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; min-height: 17px;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">let</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> firstFriend </span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">=</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> luke</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">keypaths.</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">path</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">]</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #708090; text-shadow: 0.0px 1.0px 0.0px #000000" class="">// han</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; min-height: 17px;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; color: rgb(112, 128, 144);" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">// or equivalently, with type inferred from context</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">let</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> firstFriendName </span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">=</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> luke</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">keypaths</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">.</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">friends</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; color: #990055; text-shadow: 0.0px 1.0px 0.0px #000000" class="">0</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">].</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">name</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">]</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; min-height: 17px;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; color: rgb(112, 128, 144);" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">// rename Luke's first friend</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">luke</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">firstFriendsNameKeyPath</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">]</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">=</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> </span><span style="font-kerning: none; color: #669900; text-shadow: 0.0px 1.0px 0.0px #000000" class="">"A Disreputable Smuggler"</span></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco; min-height: 17px;" class=""><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""></span><br class=""></div><div style="margin: 0px; font-size: 13px; line-height: normal; font-family: Monaco;" class=""><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">let</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> bestFriendsName </span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">=</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class=""> luke</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">[</span><span style="font-kerning: none; color: #0077aa; text-shadow: 0.0px 1.0px 0.0px #000000" class="">keypaths</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">.</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">bestFriend</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">]</span><span style="font-kerning: none; color: #a67f59; text-shadow: 0.0px 1.0px 0.0px #000000" class="">?</span><span style="font-kerning: none; color: #999999; text-shadow: 0.0px 1.0px 0.0px #000000" class="">.</span><span style="font-kerning: none; text-shadow: 0.0px 1.0px 0.0px #000000" class="">name </span><span style="font-kerning: none; color: #708090; text-shadow: 0.0px 1.0px 0.0px #000000" class="">// nil, if he is the last jedi</span></div></div><div class=""><span style="font-kerning: none; color: #708090; text-shadow: 0.0px 1.0px 0.0px #000000" class=""><br class=""></span></div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 17, 2017, at 12:27 PM, Vladimir.S via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="">On 17.03.2017 20:04, Michael LeHew via swift-evolution wrote:<br class=""><blockquote type="cite" class="">Hi friendly swift-evolution folks,<br class=""><br class="">The Foundation and Swift team would like for you to consider the following<br class="">proposal:<br class=""><br class="">Many thanks,<br class="">-Michael<br class=""><br class=""><br class=""> Smart KeyPaths: Better Key-Value Coding for Swift<br class="">...<br class=""></blockquote><br class="">Just my 2 cents. FWIW, I feel like the proposed syntax is VERY confusing.<br class=""><br class="">Person.friends[0].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.<br class=""><br class="">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".<br class=""><br class="">There is no some 'special' marker for me that saying "hey, there is references to properties used" from the first look.<br class=""><br class="">Probably we can consider another separators, like<br class=""><br class="">Person:friends[0].name<br class="">luke:path<br class=""><br class="">Person->friends[0].name<br class="">luke->path<br class=""><br class="">Person[friends[0].name] // single brackets for type<br class="">luke[[path]] // double brackets for instance<br class=""><br class="">Person@friends[0].name<br class="">luke@path<br class=""><br class="">or other with help of community.<br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></body></html>