<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Mar 29, 2017, at 8:45 PM, Douglas Gregor 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 dir="auto" class=""><div class=""><br class=""><br class="">Sent from my iPhone</div><div class=""><br class="">On Mar 29, 2017, at 4:52 PM, Brent Royal-Gordon &lt;<a href="mailto:brent@architechies.com" class="">brent@architechies.com</a>&gt; wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=us-ascii" class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 29, 2017, at 4:13 PM, Michael J LeHew Jr 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; line-break: after-white-space;" class="">Thanks for the feedback everyone! &nbsp;We have pushed a changed a bit ago to the proposal reflecting these desires.<br class=""><div class=""><br class=""></div><div class=""><a href="https://github.com/apple/swift-evolution/pull/644/files" class="">https://github.com/apple/swift-evolution/pull/644/files</a></div></div></div></blockquote><br class=""></div><div class="">Quoting from the proposal:</div><div class=""><br class=""></div><div class=""><blockquote type="cite" class="">luke[keyPath:&nbsp;#keyPath(.friends[0].name)]</blockquote><br class=""></div><div class="">Really? I can understand marking one or the other, but both, even when there's no ambiguity?</div><div class=""><br class=""></div><div class="">Let's pretend we're the type checker here. The `luke[keyPath: _]` part will create a context where we know we have an `AnyKeyPath`, `PartialKeyPath&lt;Person&gt;`, `KeyPath&lt;Person, U&gt;`, or `WritableKeyPath&lt;Person, U&gt;`. So if the core team's concern is about namespace clashes between `Person`'s static members and key paths, why not hang the key paths off the various `KeyPath` types? That is, this:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>struct Person {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var friends: [Person]</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>var name: String</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class="">Implies this:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>extension PartialKeyPath where Root == Person {</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>static let friends: WritableKeyPath&lt;Person, [Person]&gt;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">                </span>static let name: WritableKeyPath&lt;Person, String&gt;</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>}</div><div class=""><br class=""></div><div class="">And this:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>#keyPath(Person, .friends[0].name)</div><div class=""><br class=""></div><div class="">Desugars to this:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>PartialKeyPath&lt;Person&gt;.friends[0].name</div><div class=""><br class=""></div><div class="">So in a context where you already know you're passing a key path, you can simply write this:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>luke[keyPath:&nbsp;.friends[0].name]</div><div class=""><br class=""></div><div class="">Which applies normal "unresolved member" logic to look it up in `PartialKeyPath`.</div></div></blockquote><div class=""><br class=""></div>Yes, this can be done via "unresolved member lookup". It's a little different---unresolved member lookup usually can't handle chaining---but the type checker could support it.&nbsp;<div class=""><br class=""><blockquote type="cite" class=""><div class=""><br class=""></div><div class="">The result would be that you would have to explicitly, syntactically mark key paths except when the context already implied you were looking for one. In an unconstrained generic context, you would not get a key path without using `#keyPath` or explicitly naming a key path type. You would only need to worry about clashes if a call was overloaded to accept *both* `T` and `PartialKeyPath&lt;T&gt;`; if we found that possibility troubling, we could penalize unresolved member lookups that resolve to key paths, so type inference would favor static members over key paths even in those cases.</div><div class=""><br class=""></div><div class="">Would that work for people?&nbsp;</div></blockquote><div class=""><br class=""></div>It's technically feasible. It makes ".foo" more contextually sensitive, which is probably fine.&nbsp;</div></div></div></blockquote><div><br class=""></div><div>It would work nicely for the use cases I have.</div><br class=""><blockquote type="cite" class=""><div class=""><div dir="auto" class=""><div class=""><br class=""></div><div class="">&nbsp; - Doug</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><span class="Apple-style-span" style="border-collapse: separate; font-variant-ligatures: normal; font-variant-east-asian: normal; font-variant-position: normal; line-height: normal; border-spacing: 0px;"><div class=""><div style="font-size: 12px; " class=""><br class=""></div></div></span></div></blockquote></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>