<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 17, 2017, at 6:38 PM, Joe Groff via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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 Mar 17, 2017, at 12:34 PM, David Hart via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; position: relative;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">Sent off-list by mistake:</span><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""></div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;">Nice proposal. I have a few comments inline:</div><div class="" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 17 Mar 2017, at 18:04, Michael LeHew via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div dir="auto" class="" style="word-wrap: break-word; -webkit-nbsp-mode: space;"><div class=""><h4 id="toc_4" class="" style="-webkit-print-color-adjust: exact; margin: 20px 0px 10px; padding: 0px; -webkit-font-smoothing: antialiased; cursor: text; position: relative; font-size: 16px; font-family: Helvetica, arial, sans-serif; background-color: rgb(255, 255, 255);">Use/Mention Distinctions</h4><p class="" style="-webkit-print-color-adjust: exact; margin: 15px 0px; font-family: Helvetica, arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);">While methods can be referred to without invoking them (<code class="" style="-webkit-print-color-adjust: exact; margin: 0px 2px; padding: 0px 5px; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">let x = foo.bar</code>&nbsp;instead of&nbsp;&nbsp;<code class="" style="-webkit-print-color-adjust: exact; margin: 0px 2px; padding: 0px 5px; white-space: pre-wrap; border: 1px solid rgb(234, 234, 234); background-color: rgb(248, 248, 248); border-top-left-radius: 3px; border-top-right-radius: 3px; border-bottom-right-radius: 3px; border-bottom-left-radius: 3px;">let x = foo.bar()</code>), this is not currently possible for properties and subscripts.</p><p class="" style="-webkit-print-color-adjust: exact; margin: 15px 0px; font-family: Helvetica, arial, sans-serif; font-size: 14px; background-color: rgb(255, 255, 255);">Making indirect references to a properties' concrete types also lets us expose metadata about the property, and in the future additional behaviors.</p></div></div></div></div></blockquote>What metadata is attached? How is it accessed? What future features are you thinking about?</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">To begin with, you'd have limited ability to stringify a key path. Eventually we'd like to support other reflectiony things, including:</div><div class=""><br class=""></div><div class="">- Asking for the primary key paths a type supports</div><div class="">- Asking for a key by name or index</div><div class="">- Breaking a key path down by components</div></div></div></div></blockquote><br class=""></div><div>This might be my new favorite Swift feature. &lt;3 It seems obvious in retrospect, which is surely a sign of its genius.</div><br class=""><div class="">I would LOVE to be able to get the individual components in a path. Even if it were just the names, that would let me do some things that I’ve been itching to do in Swift. If the types were exposed in a type-erased container, that would be even better.</div><div class=""><br class=""></div><div class="">Something like this would be plenty of information to accomplish my goals:</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; class AnyKeyPath {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; …</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; struct Key {</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let name: String</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let rootType: Any.Type</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; let valueType: Any.Type</div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; }</div><div class=""><br class=""></div><div class="">&nbsp; &nbsp; &nbsp; &nbsp; private(set) var keys: [Key]</div><div class="">&nbsp; &nbsp; }</div><div class=""><br class=""></div><div class="">But even stringifying a key path would probably let me do most of what I wanted. I’d just need to (somewhat awkwardly) split on `.`s and handle subscripts. You mentioned that we’d have “limited” ability to stringify a key path. Can you elaborate on what that means or what the limitations would be?</div><div class=""><br class=""></div><div class="">Matt</div><div class=""><br class=""></div></body></html>