<div dir="ltr"><div dir="ltr" class="gmail_msg">Agreed—I think the parentheses have to go on the outside for this to work. In this sense, `\Person.mother.age` is an expression that returns a keypath type, with the idea that the parser is greedy and tries to take as many dotted names that follow. The parentheses halt that if needed, but the backslash needs to be bound to the type name for the part inside the parentheses to be interpreted as a keypath.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">`\(Foo.bar)` looks like it would try to evaluate `Foo.bar` first and then compute the &quot;keypath&quot; of that, which doesn&#39;t make sense, whereas `(\Foo.bar)` makes it clear that the keypath expression is being separated from whatever might come after it.</div><div class="gmail_msg"><br></div></div><br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On Sat, Apr 8, 2017 at 6:12 PM Ricardo Parada via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg">At one point I was leaning towards a trailing backslash.  Now I prefer parenthesis.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">If parentheses are used should the escape character be outside the parenthesis or inside?  For example:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><font face="Monaco" class="gmail_msg"><span class="m_-8320882351214149690m_1635481868972553232Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>let x = (\Person.mother.age).valueType</font></div><div class="gmail_msg"><font face="Monaco" class="gmail_msg"><span class="m_-8320882351214149690m_1635481868972553232Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>let y = (\Person.mother.age.valueType)</font></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">vs.</div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><div class="gmail_msg"><font face="Monaco" class="gmail_msg"><span class="m_-8320882351214149690m_1635481868972553232Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>let x = \(Person.mother.age).valueType</font></div><div class="gmail_msg"><font face="Monaco" class="gmail_msg"><span class="m_-8320882351214149690m_1635481868972553232Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>let y = \(Person.mother.age.valueType)</font></div></div><div class="gmail_msg"><font face="Monaco" class="gmail_msg"><br class="gmail_msg"></font></div><div class="gmail_msg"><br class="gmail_msg"></div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">It is a subtle difference. </div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Apr 8, 2017, at 5:47 PM, Haravikk via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-8320882351214149690m_1635481868972553232Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div style="word-wrap:break-word" class="gmail_msg"><br class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On 8 Apr 2017, at 22:18, BJ Homer via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-8320882351214149690m_1635481868972553232Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="auto" class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"></span></div><div class="gmail_msg"><div class="gmail_msg"><span class="gmail_msg"></span></div><div class="gmail_msg"><div class="gmail_msg">I love the idea of a leading and trailing backslash. It makes it much easier to read, and handles the &quot;but what if I want to access a property of a KeyPath?&quot; case really well.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">For example, these two are clearly distinct:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">  let x = \<span style="background-color:rgba(255,255,255,0)" class="gmail_msg">Person.mother.age\.valueType</span></div><div class="gmail_msg"><span style="background-color:rgba(255,255,255,0)" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="background-color:rgba(255,255,255,0)" class="gmail_msg">  let y = \Person.mother.age.valueType\</span></div><div class="gmail_msg"><span style="background-color:rgba(255,255,255,0)" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg"><span style="background-color:rgba(255,255,255,0)" class="gmail_msg">I&#39;m not sure why an &#39;age&#39; object would have a &#39;valueType&#39; 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&#39;m scanning through code.</span></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">-BJ</div></div></div></div></div></blockquote><br class="gmail_msg"></div><div class="gmail_msg">I think I&#39;d prefer brackets for that case; in your first example that reads to me like an escape of the period character, rather than &quot;this is the end of the key path&quot;. Brackets would make this consistent with escaping within strings, like so:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><font face="Monaco" class="gmail_msg"><span class="m_-8320882351214149690m_1635481868972553232Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>let x = \(Person.mother.age).valueType</font></div><div class="gmail_msg"><font face="Monaco" class="gmail_msg"><span class="m_-8320882351214149690m_1635481868972553232Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>let y = \(Person.mother.age.valueType)</font></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Which makes sense to me if you consider the backslash in this case being an escape from normal type/variable access. Put another way, normally when you type Person. you&#39;re telling Swift &quot;access this type and look for static methods/properties etc.&quot;, whereas when you &quot;escape&quot; it you&#39;re telling Swift to <b class="gmail_msg">not</b> to do that, resulting in a key-path instead.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Maybe it&#39;s a stretch, it that makes sense logically to me, plus I think the use of brackets just looks cleaner than another backslash.</div></div>_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div><br class="gmail_msg"></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div></div>