<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">At one point I was leaning towards a trailing backslash. Now I prefer parenthesis.<div class=""><br class=""></div><div class="">If parentheses are used should the escape character be outside the parenthesis or inside? For example:</div><div class=""><br class=""></div><div class=""><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let x = (\Person.mother.age).valueType</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let y = (\Person.mother.age.valueType)</font></div><div class=""><br class=""></div><div class="">vs.</div><div class=""><br class=""></div><div class=""><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let x = \(Person.mother.age).valueType</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let y = \(Person.mother.age.valueType)</font></div></div><div class=""><font face="Monaco" class=""><br class=""></font></div><div class=""><br class=""></div><div class="">It is a subtle difference. </div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><br class=""></div><div><blockquote type="cite" class=""><div class="">On Apr 8, 2017, at 5:47 PM, Haravikk 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=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 8 Apr 2017, at 22:18, BJ Homer 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=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class=""><span class=""></span></div><div class=""><div class=""><span class=""></span></div><div class=""><div class="">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 class=""><br class=""></div><div class="">For example, these two are clearly distinct:</div><div class=""><br class=""></div><div class=""> let x = \<span style="background-color: rgba(255, 255, 255, 0);" class="">Person.mother.age\.valueType</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""> let y = \Person.mother.age.valueType\</span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class=""><br class=""></span></div><div class=""><span style="background-color: rgba(255, 255, 255, 0);" class="">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 class=""><br class=""></div><div class="">-BJ</div></div></div></div></div></blockquote><br class=""></div><div class="">I think I'd prefer brackets for that case; in your first example that reads to me like an escape of the period character, rather than "this is the end of the key path". Brackets would make this consistent with escaping within strings, like so:</div><div class=""><br class=""></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let x = \(Person.mother.age).valueType</font></div><div class=""><font face="Monaco" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let y = \(Person.mother.age.valueType)</font></div><div class=""><br class=""></div><div class="">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're telling Swift "access this type and look for static methods/properties etc.", whereas when you "escape" it you're telling Swift to <b class="">not</b> to do that, resulting in a key-path instead.</div><div class=""><br class=""></div><div class="">Maybe it'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="">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></blockquote></div><br class=""></div></body></html>