<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 12. Jul 2017, at 22:21, Dave Abrahams 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 class=""><br class="">on Tue Jul 11 2017, Robert Bennett &lt;<a href="http://rltbennett-AT-icloud.com" class="">rltbennett-AT-icloud.com</a>&gt; wrote:<br class=""><br class=""><blockquote type="cite" class="">Just realized that even inout functions don’t let you do<br class="">member(object) = value. <br class=""></blockquote><br class="">The other difference is that an inout function can't be used to get a<br class="">member from an immutable value, whereas a keypath/subscript/property<br class="">access can.<br class=""><br class=""><br class="">-- <br class="">-Dave<br class="">_______________________________________________<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></div></blockquote></div><br class=""><div class="">Hmm… I forgot about setters.</div><div class=""><br class=""></div><div class="">I would still like some simple way to use a KeyPath where an equivalent closure would be expected (for getters AND setters). The operator approach looks like the best one, but I’d prefer a prefix operator, so…</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><font face="Menlo" class="">\MyObj.something.name &nbsp;// returns KeyPath&lt;MyObj, String&gt;</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">^\MyObj.something.name // returns (MyObj)-&gt;String</font></div><div class=""><font face="Menlo" class="">^myKeyPath &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // as above.</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div><div class=""><font face="Menlo" class="">*\MyObj.something.name // returns (inout MyObj, String)-&gt;Void</font></div><div class=""><font face="Menlo" class="">*myKeyPath &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; // as above.</font></div><div class=""><font face="Menlo" class=""><br class=""></font></div></blockquote><div class=""><br class=""></div><div class="">Where those operators could, either now or later, be backed by some kind of protocol (similar to Equatable/Comparable) to express general-purpose callable objects.</div><div class=""><br class=""></div>But I don’t like how cryptic it all looks.<div class=""><br class=""></div><div class="">- Karl</div></body></html>