<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="">Another thought on the use of single quotes (an possibly the proposed escape character). Do you think the closing single quote could be made optional since key paths cannot have spaces? Or would that be confusing for beginners?<div class=""><br class=""></div><div class="">For example, these two would be equivalent:</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><font class="" face="Monaco" style="background-color: rgba(255, 255, 255, 0); font-size: 12px;"> let isPuppyPredicate = '<font class="" color="#980096">Pet.type</font> == .dog && <font class="" color="#980096">'Pet.age</font> < 12</font></div></div><div class=""><font class="" face="Monaco" style="background-color: rgba(255, 255, 255, 0); font-size: 12px;"> let isPuppyPredicate = '<font class="" color="#980096">Pet.type</font></font><span style="font-family: Monaco; font-size: 12px;" class="">'</span><span style="font-size: 12px; background-color: rgba(255, 255, 255, 0); font-family: Monaco;" class=""> == .dog && </span><font class="" color="#980096" style="font-size: 12px; background-color: rgba(255, 255, 255, 0); font-family: Monaco;">'Pet.age</font><span style="font-family: Monaco; font-size: 12px;" class="">'</span><span style="font-family: Monaco; font-size: 12px; background-color: rgba(255, 255, 255, 0);" class=""> < 12</span></div></div><div class=""><br class=""></div><div class=""><div class="">Or this:</div><div class=""><br class=""></div><div class=""><div class=""><div class=""><font class="" face="Monaco" style="background-color: rgba(255, 255, 255, 0); font-size: 12px;"> let isPuppyPredicate = \<font class="" color="#980096">Pet.type</font> == .dog && \<font class="" color="#980096">Pet.age</font> < 12</font></div></div><div class=""><font class="" face="Monaco" style="background-color: rgba(255, 255, 255, 0); font-size: 12px;"> let isPuppyPredicate = \<font class="" color="#980096">Pet.type\</font></font><span style="font-size: 12px; background-color: rgba(255, 255, 255, 0); font-family: Monaco;" class=""> == .dog && \</span><font class="" color="#980096" style="font-size: 12px; background-color: rgba(255, 255, 255, 0); font-family: Monaco;">Pet.age\</font><span style="font-family: Monaco; font-size: 12px; background-color: rgba(255, 255, 255, 0);" class=""> < 12</span></div></div><div class=""><br class=""></div></div><div class="">You would use the closing character normally when wanting to invoke a method on the key path object.</div><div class=""><br class=""></div><div class="">Any thoughts?</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 6, 2017, at 11:13 AM, Ricardo Parada 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="">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. <br class=""><br class=""><br class=""><blockquote type="cite" class="">On Apr 6, 2017, at 11:08 AM, Sean Heber via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:<br class=""><br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">That's an interesting point. While `\` alone seems acceptable, I think it's unfortunate that we'll have `(\...)` and `\(...)` both in the language.<br class="">Can we maybe consider instead:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let firstFriendsNameKeyPath = \Person.friends[0].name\<br class=""></blockquote><br class="">'Single quotes' (i.e. U+0027 APOSTROPHE) are available AFAIK:<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// Create a key path and use it<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let firstFriendsNameKeyPath = 'Person.friends[0].name'<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>luke[keyPath: firstFriendsNameKeyPath] // "Han Solo"<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// or equivalently, with type inferred from context<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>luke[keyPath: '.friends[0].name'] // "Han Solo"<br class=""><br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>// [SE-0042][SR-3550] Unapplied method references<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>'String.lowercased()' // (String) -> String<br class=""><span class="Apple-tab-span" style="white-space:pre">        </span>'String.lowercased(with:)' // (String, Locale?) -> String<br class=""><br class="">Unlike the Lisp-style backtick, an apostrophe would appear on *both* ends of the key path (or method reference).<br class=""></blockquote><br class="">For what it’s worth, I much rather prefer this approach and was going to suggest it today. In Objective-C, keypaths were just strings so by using a single tick, they still look *almost* like strings, but now they’re safe and checked by the compiler - magical.<br class=""><br class="">l8r<br class="">Sean<br class=""><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=""></blockquote><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=""></div></body></html>