<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div><span></span></div><div><div><span></span></div><div><div>I love the idea of a leading and trailing backslash. It makes it much easier to read, and handles the "but what if I want to access a property of a KeyPath?" case really well.</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">For example, these two are clearly distinct:</div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">&nbsp; let x = \<span style="background-color: rgba(255, 255, 255, 0);">Person.mother.age\.valueType</span></div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);">&nbsp; let y = \Person.mother.age.valueType\</span></div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);"><br></span></div><div id="AppleMailSignature"><span style="background-color: rgba(255, 255, 255, 0);">I'm not sure why an 'age' object would have a 'valueType' property, but this variant makes it easy to handle. Even in cases where no disambiguation is required, having the trailing backslash makes it much easier to read as I'm scanning through code.</span></div><div id="AppleMailSignature"><br></div><div id="AppleMailSignature">-BJ</div><div><br>On Apr 5, 2017, at 9:13 PM, Xiaodi Wu via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br><br></div><blockquote type="cite"><div><div dir="ltr">On Wed, Apr 5, 2017 at 9:21 PM, Ricardo Parada via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span class="gmail-"><br><div><blockquote type="cite"><div>On Apr 5, 2017, at 9:41 PM, Brent Royal-Gordon via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="gmail-m_-7606062616642485556Apple-interchange-newline"><div><span style="font-family:helvetica;font-size:14px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;float:none;display:inline">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.</span><br class="gmail-m_-7606062616642485556Apple-interchange-newline"></div></blockquote></div><br></span><div>Good point.&nbsp;</div><div><br></div><div>&nbsp;I'm thinking about the hypothetical code examples from previous emails:</div><div><br></div><div><blockquote type="cite"><div></div></blockquote></div><div><span class="gmail-"><div><font face="Monaco" style="font-size:12px">&nbsp; &nbsp;let isPuppyQualifier = <font color="#af00f4">\Pet.type</font> == .dog &amp;&amp; <font color="#af00f4">\Pet.age</font> &lt; 12</font></div></span><div><font face="Monaco" style="font-size:12px">&nbsp; &nbsp;let familyQualifier =&nbsp;</font><span style="font-family:monaco;font-size:12px">(</span><font face="Monaco" style="font-size:12px"><font color="#af00f4">\Family.pets</font></font><span style="font-family:monaco;font-size:12px">)</span><font face="Monaco" style="font-size:12px">.contains(<wbr>where: isPuppyQualifier)</font></div><span class="gmail-"><div><font face="Monaco" style="font-size:12px">&nbsp; &nbsp;let familiesWithPuppies = Family.fetch(editingContext, familyQualifier)</font></div></span></div><div><div><br></div></div></div></blockquote><div><br></div><div>That's an interesting point. While `\` alone seems acceptable, I think it's unfortunate that we'll have `(\...)` and `\(...)` both in the language.</div><div>Can we maybe consider instead:</div><div><br></div><div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>let firstFriendsNameKeyPath = \Person.friends[0].name\</div><div><br></div><div>It is also worth mentioning that, with the sigil, the `keyPath` label may not be so necessary:</div><div><br></div><div><span class="gmail-Apple-tab-span" style="white-space:pre">        </span>print(luke[\.friends[0].name])</div></div><div><span style="white-space:pre">        // or, if the suggestion above is accepted</span><br></div><div><span style="white-space:pre">        print(luke[\.friends[0].name\])</span><span style="white-space:pre"><br></span></div></div><br></div></div>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>swift-evolution mailing list</span><br><span><a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a></span><br><span><a href="https://lists.swift.org/mailman/listinfo/swift-evolution">https://lists.swift.org/mailman/listinfo/swift-evolution</a></span><br></div></blockquote></div></div></body></html>