<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="">I did not mention single quotes because I was assuming those were reserved for string literals.<div class=""><br class=""></div><div class="">But if they are available for something like this, it would make it obvious where the key path begins and where it ends. I went through my hypothetical code samples, and I don't mind the \ escape character. For instance:</div><div class=""><br class=""></div><div class=""><div class=""><font class="" style="background-color: rgba(255, 255, 255, 0); font-size: 12px;" face="Monaco"> let isPuppyPredicate = <font class="" color="#980096">\Pet.type</font> == .dog && <font class="" color="#980096">\Pet.age</font> < 12</font></div><div class=""><span style="background-color: rgba(255, 255, 255, 0); font-size: 12px;" class=""><font face="Monaco" class=""><font class=""> let hasPuppiesPredicate = (</font><font class=""><font class=""><font color="#980096" class="">\Family.pets</font>)</font></font><font class="">.any(isPuppyPredicate)</font></font></span></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"> let familiesWithPuppies = Family.fetch(editingContext, </font><font class="" style="background-color: rgba(255, 255, 255, 0);">hasPuppiesPredicate</font><font class="" style="background-color: rgba(255, 255, 255, 0);">)</font></font></div><div class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font></div><div class="">I don't mind having to use parenthesis sometimes when invoking a method on key path for example.</div><div class=""><br class=""></div><div class="">With single quotes it would look like this:</div><div class=""><br class=""></div><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 class=""><span style="background-color: rgba(255, 255, 255, 0); font-size: 12px;" class=""><font face="Monaco" class=""><font class=""> let hasPuppiesPredicate = '</font><font class=""><font class=""><font color="#980096" class="">Family.pets'</font></font></font><font class="">.any(isPuppyPredicate)</font></font></span></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"> let familiesWithPuppies = Family.fetch(editingContext, </font><font class="" style="background-color: rgba(255, 255, 255, 0);">hasPuppiesPredicate</font><font class="" style="background-color: rgba(255, 255, 255, 0);">)</font></font></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font></font></div><div class=""><font face="Monaco" class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"><span style="font-size: 12px;" class="">And creating orderings for example:</span></font></font></div><div class=""><font face="Monaco" class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"><span style="font-size: 12px;" class=""><br class=""></span></font></font></div><div class=""><div class=""><font class="" face="Monaco"><span style="background-color: rgba(255, 255, 255, 0); font-size: 12px;" class=""> let orderings = [ '</span><font class="" color="#980096" style="background-color: rgba(255, 255, 255, 0); font-size: 12px;">Order.totalAmount'</font><font class="" style="font-size: 12px;">.desc, </font><span style="background-color: rgba(255, 255, 255, 0); font-size: 12px;" class=""> </span></font><span style="font-family: Monaco; background-color: rgba(255, 255, 255, 0); font-size: 12px;" class="">'</span><font class="" color="#980096" style="font-family: Monaco; background-color: rgba(255, 255, 255, 0); font-size: 12px;">Order.address.zip</font><font class="" style="font-family: Monaco; font-size: 12px;">'.asc ]</font></div><div class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><font face="Monaco" style="font-size: 12px;" class=""><font class="" style="background-color: rgba(255, 255, 255, 0);"><br class=""></font></font></div></div><div><blockquote type="cite" class=""><div class="">On Apr 6, 2017, at 9:55 AM, Ben Rimmington 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="">Re: <<a href="https://github.com/apple/swift-evolution/blob/master/proposals/0161-key-paths.md#referencing-key-paths" class="">https://github.com/apple/swift-evolution/blob/master/proposals/0161-key-paths.md#referencing-key-paths</a>><br class=""><br class=""><blockquote type="cite" class="">On 6 Apr 2017, at 04:13, Xiaodi Wu wrote:<br class=""><br class=""><blockquote type="cite" class="">On Wed, Apr 5, 2017 at 9:21 PM, Ricardo Parada wrote:<br class=""><br class=""><blockquote type="cite" class="">On Apr 5, 2017, at 9:41 PM, Brent Royal-Gordon wrote:<br class=""><br class="">It's worth noting that, if you write `\Person.name.valueType`, this syntax is ambiguous—it could mean "make a key path for the `valueType` property on `name` property of `Person`", or it could mean "make a key path for the `name` property of `Person`, then access the key path's `valueType` property". We can solve this by always interpreting it as the former and requiring parentheses for the latter—that is, `(\Person.name).valueType`—but I thought it was worth calling out explicitly.<br class=""></blockquote><br class="">Good point. <br class=""><br class=""> I'm thinking about the hypothetical code examples from previous emails:<br class=""><br class=""> let isPuppyQualifier = \Pet.type == .dog && \Pet.age < 12<br class=""> let familyQualifier = (\Family.pets).contains(where: isPuppyQualifier)<br class=""> let familiesWithPuppies = Family.fetch(editingContext, familyQualifier)<br class=""></blockquote><br 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=""><br class="">-- Ben<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=""></div></div></blockquote></div><br class=""></div></body></html>