<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 Apr 5, 2017, at 7:32 PM, David Smith 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=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">The rationale for using the same syntax is that a KeyPath is an unapplied property/subscript access. Even the multi-segment part of it isn't necessarily dissimilar: I don't think it would be unreasonable to imagine that \Foo.someMethod.someOtherMethod could work*, that'd just be function composition after all.<div class=""><br class=""></div><div class="">KeyPath : Properties/Subscripts :: Functions with a self argument : Methods<br class=""><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>David</div><div class=""><br class=""></div><div class="">*not proposing this, haven't thought carefully about whether there are edge cases I'm missing here, but I think the analogy holds</div></div></div></div></blockquote><div><br class=""></div><div>I alluded to this kind of thing in the earlier threads. &nbsp;It would be very cool to see this explored in the future.</div><div><br class=""></div><div>I really like the latest draft and am eagerly anticipating Smart KeyPaths being implemented. &nbsp;Thank you for listening to feedback from the community!</div><div><br class=""></div><div>One possible future direction I have been wondering about is whether it might be interesting to expose an anonymous type for each distinct key path which would have static members for getting (and setting if mutable) the value. &nbsp;The types would inherit from the most specific matching key path type included in this proposal. &nbsp;This would allow us pass key paths statically using the type system and therefore not requiring any runtime overhead. &nbsp;</div><div><br class=""></div><div>I have experimented with this approach in some of my own code and it looks like it would be a very promising approach aside from the boilerplate required to write these types manually. &nbsp;I have abandoned this approach for now because of the boilerplate and because the syntactic sugar of the key path shorthand in this proposal is too attractive to pass up. &nbsp;I would love to explore it again in the future if key paths were to support this approach.</div><div><br class=""></div><div>Matthew</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 5, 2017, at 5:16 PM, Patrick Smith 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="">I too find the backslash odd, as it’s usually of course used to escape something.<br class=""><br class="">What about three periods?<br class=""><br class="">        let firstFriendsNameKeyPath = Person...friends[0].name<br class="">        print(luke[keyPath: ...friends[0].name])<br class=""><br class=""><br class="">I also find wanting to use the same syntax for unapplied methods strange, as they would product two totally different things: one a key path value, the other a function.<br class=""><br class="">Patrick<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Thu, 6 Apr 2017 at 10:00 am, Douglas Gregor via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On Apr 5, 2017, at 4:55 PM, Colin Barrett &lt;<a href="mailto:colin@springsandstruts.com" class="gmail_msg" target="_blank">colin@springsandstruts.com</a>&gt; wrote:</div><br class="m_-4532215789157486227Apple-interchange-newline gmail_msg"><div class="gmail_msg"><div dir="ltr" style="font-family:Helvetica;font-size:12px;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" class="gmail_msg">Is the choice of backslash up for review? I think another operator, </div></div></blockquote><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">We talked through basically everything on the keyboard, and there really aren’t other options that don’t stomp on existing behavior.</div></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" style="font-family:Helvetica;font-size:12px;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" class="gmail_msg">perhaps backtick (`), would work better. </div></div></blockquote><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">Backtick (`) is already taken for escaping identifiers, e.g.,&nbsp;</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_-4532215789157486227Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>var `func` = { /* some code */ }</div><br class="gmail_msg"></div><div class="gmail_msg"><span class="m_-4532215789157486227Apple-tab-span gmail_msg" style="white-space:pre-wrap">        </span>- Doug</div><div class="gmail_msg"><br class="gmail_msg"></div><br class="gmail_msg"></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>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></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=""></body></html>