<div dir="ltr">It&#39;s so nice that this is finally seeing the light of day :) Great work everyone!<div><br></div><div>Re: subscripts, it&#39;s definitely a great solution for &quot;the Swift we have now&quot;, but I&#39;m not sure in &quot;the Swift we&#39;ll have in a few years.&quot; If, for instance, someday we&#39;re able to return inouts (or really just lvalues in general), we&#39;d be able to do a lot of this with regular functions and some combinators.</div><div><br></div><div>Count me as a +1 for the Lisp-style syntax. If ` isn&#39;t to people&#39;s liking, I wonder about @. I think both &quot;luke @  .friends[0].name&quot; and &quot; .friends[0].name @ luke&quot; read quiet nicely, and gives the idea of a key path as a kind of addressing scheme.</div><div><br></div><div><div>-Colin</div><div><br></div><div>P.S. Has anyone thought about writing an HTTP + JSON DSL with these?<br><br><div class="gmail_quote"><div dir="ltr">On Fri, Mar 17, 2017 at 1:04 PM Michael LeHew via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>&gt; wrote:<br></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;line-break:after-white-space" class="gmail_msg"><div dir="auto" style="word-wrap:break-word;line-break:after-white-space" class="gmail_msg">Hi friendly swift-evolution folks,<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">The Foundation and Swift team  would like for you to consider the following proposal:</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Many thanks,</div><div class="gmail_msg">-Michael</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><h1 id="m_5490037692365906541toc_0" style="margin:0px 0px 10px;padding:0px;font-size:28px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Smart KeyPaths: Better Key-Value Coding for Swift</h1><ul style="margin:15px 0px;padding-left:30px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="margin:0px" class="gmail_msg">Proposal: SE-NNNN</li><li style="margin:0px" class="gmail_msg">Authors: <a href="https://github.com/Catfish-Man" style="color:rgb(65,131,196);margin-top:0px" class="gmail_msg" target="_blank">David Smith</a>, <a href="https://github.com/mlehew" style="color:rgb(65,131,196)" class="gmail_msg" target="_blank">Michael LeHew</a>, <a href="https://github.com/jckarter" style="color:rgb(65,131,196)" class="gmail_msg" target="_blank">Joe Groff</a></li><li style="margin:0px" class="gmail_msg">Review Manager: TBD</li><li style="margin:0px" class="gmail_msg">Status: <strong style="margin-top:0px" class="gmail_msg">Awaiting Review</strong></li><li style="margin:0px" class="gmail_msg">Associated PRs:<ul style="margin:0px 0px 15px;padding-left:30px" class="gmail_msg"><li style="margin:0px" class="gmail_msg"><a href="https://github.com/apple/swift-evolution/pull/644" style="color:rgb(65,131,196);margin-top:0px" class="gmail_msg" target="_blank">#644</a></li></ul></li></ul><h2 id="m_5490037692365906541toc_1" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Introduction</h2><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">We propose a family of concrete <em class="gmail_msg">Key Path</em> types that represent uninvoked references to properties that can be composed to form paths through many values and directly get/set their underlying values.</p><h2 id="m_5490037692365906541toc_2" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Motivation</h2><h4 id="m_5490037692365906541toc_3" style="margin:20px 0px 10px;padding:0px;font-size:16px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">We Can Do Better than String</h4><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">On Darwin platforms Swift&#39;s existing <code style="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" class="gmail_msg">#keyPath()</code> syntax provides a convenient way to safely <em class="gmail_msg">refer</em> to properties. Unfortunately, once validated, the expression becomes a <code style="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" class="gmail_msg">String</code> which has a number of important limitations:</p><ul style="margin:15px 0px;padding-left:30px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="margin:0px" class="gmail_msg">Loss of type information (requiring awkward <code style="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" class="gmail_msg">Any</code> APIs)</li><li style="margin:0px" class="gmail_msg">Unnecessarily slow to parse</li><li style="margin:0px" class="gmail_msg">Only applicable to <code style="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" class="gmail_msg">NSObjects</code></li><li style="margin:0px" class="gmail_msg">Limited to Darwin platforms</li></ul><h4 id="m_5490037692365906541toc_4" style="margin:20px 0px 10px;padding:0px;font-size:16px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Use/Mention Distinctions</h4><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">While methods can be referred to without invoking them (<code style="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" class="gmail_msg">let x = foo.bar</code> instead of  <code style="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" class="gmail_msg">let x = foo.bar()</code>), this is not currently possible for properties and subscripts.</p><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">Making indirect references to a properties&#39; concrete types also lets us expose metadata about the property, and in the future additional behaviors.</p><h4 id="m_5490037692365906541toc_5" style="margin:20px 0px 10px;padding:0px;font-size:16px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">More Expressive KeyPaths</h4><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">We would also like to support being able to use <em class="gmail_msg">Key Paths</em> to access into collections, which is not currently possible.</p><h2 id="m_5490037692365906541toc_6" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Proposed solution</h2><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">We propose introducing a new expression akin to <code style="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" class="gmail_msg">Type.method</code>, but for properties and subscripts. These property reference expressions produce <code style="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" class="gmail_msg">KeyPath</code> objects, rather than <code style="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" class="gmail_msg">Strings</code>. <code style="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" class="gmail_msg">KeyPaths</code> are a family of generic classes <em class="gmail_msg">(structs and protocols here would be ideal, but requires generalized existentials)</em> which encapsulate a property reference or chain of property references, including the type, mutability, property name(s), and ability to set/get values.</p><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">Here&#39;s a sample of it in use:</p><div style="font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><div class="m_5490037692365906541prism-show-language gmail_msg"><div class="m_5490037692365906541prism-show-language-label gmail_msg" style="background-color:rgb(207,207,207);display:inline-block;width:auto;height:auto;font-size:0.9em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:5px;padding:0px 0.5em">Swift</div></div><pre class="m_5490037692365906541language-swift gmail_msg" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(245,242,240);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal"><code class="m_5490037692365906541language-swift gmail_msg" style="margin:0px;padding:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:none;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5"><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">struct</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Person</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">var</span> name<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">String</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">var</span> friends<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Person</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">var</span> bestFriend<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Person</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">?</span>
<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span>

<span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">var</span> han <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">=</span> <span class="m_5490037692365906541token m_5490037692365906541function gmail_msg" style="color:rgb(221,74,104)">Person</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>name<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541string gmail_msg" style="color:rgb(102,153,0)">&quot;Han Solo&quot;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> friends<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span>
<span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">var</span> luke <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">=</span> <span class="m_5490037692365906541token m_5490037692365906541function gmail_msg" style="color:rgb(221,74,104)">Person</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>name<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541string gmail_msg" style="color:rgb(102,153,0)">&quot;Luke Skywalker&quot;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> friends<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span>han<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span>

<span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">let</span> firstFriendsNameKeyPath <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">=</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Person</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span>friends<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span><span class="m_5490037692365906541token m_5490037692365906541number gmail_msg" style="color:rgb(153,0,85)">0</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span>name

<span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">let</span> firstFriend <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">=</span> luke<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span> <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// han</span>

<span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// or equivalently, with type inferred from context</span>
<span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">let</span> firstFriendName <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">=</span> luke<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span>friends<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span><span class="m_5490037692365906541token m_5490037692365906541number gmail_msg" style="color:rgb(153,0,85)">0</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span>name<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span>

<span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// rename Luke&#39;s first friend</span>
luke<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span>firstFriendsNameKeyPath<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">=</span> <span class="m_5490037692365906541token m_5490037692365906541string gmail_msg" style="color:rgb(102,153,0)">&quot;A Disreputable Smuggler&quot;</span>

<span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">let</span> bestFriendsName <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">=</span> luke<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span>bestFriend<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">?</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span>name  <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// nil, if he is the last jedi</span></code></pre></div><h2 id="m_5490037692365906541toc_7" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Detailed design</h2><h3 id="m_5490037692365906541toc_8" style="margin:20px 0px 10px;padding:0px;font-size:18px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Core KeyPath Types</h3><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><code style="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" class="gmail_msg">KeyPaths</code> are a hierarchy of progressively more specific classes, based on whether we have prior knowledge of the path through the object graph we wish to traverse. </p><h5 id="m_5490037692365906541toc_9" style="margin:20px 0px 10px;padding:0px;font-size:14px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Unknown Path / Unknown Root Type</h5><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><code style="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" class="gmail_msg">AnyKeyPath</code> is fully type-erased, referring to &#39;any route&#39; through an object/value graph for &#39;any root&#39;. Because of type-erasure many operations can fail at runtime and are thus nillable. </p><div style="font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><div class="m_5490037692365906541prism-show-language gmail_msg"><div class="m_5490037692365906541prism-show-language-label gmail_msg" style="background-color:rgb(207,207,207);display:inline-block;width:auto;height:auto;font-size:0.9em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:5px;padding:0px 0.5em">Swift</div></div><pre class="m_5490037692365906541language-swift gmail_msg" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(245,242,240);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal"><code class="m_5490037692365906541language-swift gmail_msg" style="margin:0px;padding:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:none;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5"><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">class</span> <span class="m_5490037692365906541token m_5490037692365906541class-name gmail_msg">AnyKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">CustomDebugStringConvertible</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Hashable</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span>
    <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// MARK - Composition</span>
    <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// Returns nil if path.rootType != self.valueType</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> <span class="m_5490037692365906541token m_5490037692365906541function gmail_msg" style="color:rgb(221,74,104)">appending</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AnyKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AnyKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">?</span>
    
    <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// MARK - Runtime Information        </span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">class</span> <span class="m_5490037692365906541token m_5490037692365906541class-name gmail_msg">var</span> rootType<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Any</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">Type</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">class</span> <span class="m_5490037692365906541token m_5490037692365906541class-name gmail_msg">var</span> valueType<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Any</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">Type</span>
    
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">static</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">==</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>lhs<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AnyKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> rhs<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AnyKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Bool</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">var</span> hashValue<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Int</span>
<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span></code></pre></div><h5 id="m_5490037692365906541toc_10" style="margin:20px 0px 10px;padding:0px;font-size:14px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Unknown Path / Known Root Type</h5><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">If we know a little more type information (what kind of thing the key path is relative to), then we can use <code style="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" class="gmail_msg">PartialKeyPath &lt;Root&gt;</code>, which refers to an &#39;any route&#39; from a known root:</p><div style="font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><div class="m_5490037692365906541prism-show-language gmail_msg"><div class="m_5490037692365906541prism-show-language-label gmail_msg" style="background-color:rgb(207,207,207);display:inline-block;width:auto;height:auto;font-size:0.9em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:5px;padding:0px 0.5em">Swift</div></div><pre class="m_5490037692365906541language-swift gmail_msg" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(245,242,240);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal"><code class="m_5490037692365906541language-swift gmail_msg" style="margin:0px;padding:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:none;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5"><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">class</span> <span class="m_5490037692365906541token m_5490037692365906541class-name gmail_msg">PartialKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AnyKeyPath</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span>
    <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// MARK - Composition</span>
    <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// Returns nil if Value != self.valueType</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> <span class="m_5490037692365906541token m_5490037692365906541function gmail_msg" style="color:rgb(221,74,104)">appending</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AnyKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">PartialKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">?</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> appending<span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">KeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">KeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">?</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> appending<span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">ReferenceKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">ReferenceKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">?</span>
<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span></code></pre></div><h5 id="m_5490037692365906541toc_11" style="margin:20px 0px 10px;padding:0px;font-size:14px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Known Path / Known Root Type</h5><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">When we know both what the path is relative to and what it refers to, we can use <code style="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" class="gmail_msg">KeyPath</code>. Thanks to the knowledge of the Root and Value types, all of the failable operations lose their Optional. </p><div style="font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><div class="m_5490037692365906541prism-show-language gmail_msg"><div class="m_5490037692365906541prism-show-language-label gmail_msg" style="background-color:rgb(207,207,207);display:inline-block;width:auto;height:auto;font-size:0.9em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:5px;padding:0px 0.5em">Swift</div></div><pre class="m_5490037692365906541language-swift gmail_msg" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(245,242,240);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal"><code class="m_5490037692365906541language-swift gmail_msg" style="margin:0px;padding:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:none;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5"><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">public</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">class</span> <span class="m_5490037692365906541token m_5490037692365906541class-name gmail_msg">KeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">PartialKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span>
    <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// MARK - Composition</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> appending<span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">KeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">KeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> appending<span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">WritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">Self</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> appending<span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">ReferenceWritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">ReferenceWritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span>
<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span></code></pre></div><h5 id="m_5490037692365906541toc_12" style="margin:20px 0px 10px;padding:0px;font-size:14px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Value/Reference Mutation Semantics Mutation</h5><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">Finally, we have a pair of subclasses encapsulating value/reference mutation semantics. These have to be distinct because mutating a copy of a value is not very useful, so we need to mutate an inout value.</p><div style="font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><div class="m_5490037692365906541prism-show-language gmail_msg"><div class="m_5490037692365906541prism-show-language-label gmail_msg" style="background-color:rgb(207,207,207);display:inline-block;width:auto;height:auto;font-size:0.9em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:5px;padding:0px 0.5em">Swift</div></div><pre class="m_5490037692365906541language-swift gmail_msg" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(245,242,240);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal"><code class="m_5490037692365906541language-swift gmail_msg" style="margin:0px;padding:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:none;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5"><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">class</span> <span class="m_5490037692365906541token m_5490037692365906541class-name gmail_msg">WritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">KeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span>
    <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// MARK - Composition</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> appending<span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedPathValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">WritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedPathValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">WritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedPathValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span>
<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span>

<span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">class</span> <span class="m_5490037692365906541token m_5490037692365906541class-name gmail_msg">ReferenceWritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">WritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">override</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">func</span> appending<span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedPathValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">WritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedPathValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">ReferenceWritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AppendedPathValue</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span>
<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span></code></pre></div><h3 id="m_5490037692365906541toc_13" style="margin:20px 0px 10px;padding:0px;font-size:18px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Access and Mutation Through KeyPaths</h3><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">To get or set values for a given root and key path we effectively add the following subscripts to all Swift types. </p><div style="font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><div class="m_5490037692365906541prism-show-language gmail_msg"><div class="m_5490037692365906541prism-show-language-label gmail_msg" style="background-color:rgb(207,207,207);display:inline-block;width:auto;height:auto;font-size:0.9em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:5px;padding:0px 0.5em">Swift</div></div><pre class="m_5490037692365906541language-swift gmail_msg" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(245,242,240);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal"><code class="m_5490037692365906541language-swift gmail_msg" style="margin:0px;padding:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:none;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5"><span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">extension</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Any</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">subscript</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">AnyKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Any</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">?</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">get</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">subscript</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">Self</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">PartialKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Any</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">get</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">subscript</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">Self</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">KeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">get</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span>
    <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">subscript</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">Self</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">(</span>path<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">:</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">WritableKeyPath</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&lt;</span><span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Root</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">)</span> <span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">-</span><span class="m_5490037692365906541token m_5490037692365906541operator gmail_msg" style="color:rgb(166,127,89);background-color:rgba(255,255,255,0.498039);background-position:initial initial;background-repeat:initial initial">&gt;</span> <span class="m_5490037692365906541token m_5490037692365906541builtin gmail_msg" style="color:rgb(102,153,0)">Value</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">{</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">set</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">,</span> <span class="m_5490037692365906541token m_5490037692365906541keyword gmail_msg" style="color:rgb(0,119,170)">get</span> <span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span>
<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">}</span></code></pre></div><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">This allows for code like</p><div style="font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><div class="m_5490037692365906541prism-show-language gmail_msg"><div class="m_5490037692365906541prism-show-language-label gmail_msg" style="background-color:rgb(207,207,207);display:inline-block;width:auto;height:auto;font-size:0.9em;border-top-left-radius:0px;border-top-right-radius:0px;border-bottom-right-radius:0px;border-bottom-left-radius:5px;padding:0px 0.5em">Swift</div></div><pre class="m_5490037692365906541language-swift gmail_msg" style="margin-top:0.5em;margin-bottom:0.5em;background-color:rgb(245,242,240);border:1px solid rgb(204,204,204);font-size:13px;line-height:1.5;white-space:pre-wrap;overflow:auto;padding:1em;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal"><code class="m_5490037692365906541language-swift gmail_msg" style="margin:0px;padding:0px;border:none;border-top-left-radius:3px;border-top-right-radius:3px;border-bottom-right-radius:3px;border-bottom-left-radius:3px;background-image:none;font-family:Consolas,Monaco,&#39;Andale Mono&#39;,&#39;Ubuntu Mono&#39;,monospace;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5">person<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">[</span><span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">.</span>name<span class="m_5490037692365906541token m_5490037692365906541punctuation gmail_msg" style="color:rgb(153,153,153)">]</span> <span class="m_5490037692365906541token m_5490037692365906541comment gmail_msg" style="color:slategray">// Self.type is inferred</span></code></pre></div><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">which is both appealingly readable, and doesn&#39;t require read-modify-write copies (subscripts access <code style="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" class="gmail_msg">self</code> inout). Conflicts with existing subscripts are avoided by using generic subscripts to specifically only accept key paths with a <code style="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" class="gmail_msg">Root</code> of the type in question.</p><h3 id="m_5490037692365906541toc_14" style="margin:20px 0px 10px;padding:0px;font-size:18px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Referencing Key Paths</h3><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">Forming a <code style="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" class="gmail_msg">KeyPath</code> borrows from the same syntax used to reference methods and initializers,<code style="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" class="gmail_msg">Type.instanceMethod</code> only now working for properties and collections. Optionals are handled via optional-chaining. Multiply dotted expressions are allowed as well, and work just as if they were composed via the <code style="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" class="gmail_msg">appending</code> methods on <code style="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" class="gmail_msg">KeyPath</code>.</p><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">There is no change or interaction with the #keyPath() syntax introduced in Swift 3. </p><h3 id="m_5490037692365906541toc_15" style="margin:20px 0px 10px;padding:0px;font-size:18px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Performance</h3><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">The performance of interacting with a property via <code style="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" class="gmail_msg">KeyPaths</code> should be close to the cost of calling the property directly.</p><h2 id="m_5490037692365906541toc_16" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Source compatibility</h2><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">This change is additive and there should no affect on existing source. </p><h2 id="m_5490037692365906541toc_17" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Effect on ABI stability</h2><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">This feature adds the following requirements to ABI stability: </p><ul style="margin:15px 0px;padding-left:30px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg"><li style="margin:0px" class="gmail_msg">mechanism to access key paths of public properties</li></ul><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">We think a protocol-based design would be preferable once the language has sufficient support for generalized existentials to make that ergonomic. By keeping the class hierarchy closed and the concrete implementations private to the implementation it should be tractable to provide compatibility with an open protocol-based design in the future.</p><h2 id="m_5490037692365906541toc_18" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Effect on API resilience</h2><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">This should not significantly impact API resilience, as it merely provides a new mechanism for operating on existing APIs.</p><h2 id="m_5490037692365906541toc_19" style="margin:20px 0px 10px;padding:0px;font-size:24px;border-bottom-width:1px;border-bottom-style:solid;border-bottom-color:rgb(204,204,204);font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">Alternatives considered</h2><h4 id="m_5490037692365906541toc_20" style="margin:20px 0px 10px;padding:0px;font-size:16px;font-family:Helvetica,arial,sans-serif;background-color:rgb(255,255,255)" class="gmail_msg">More Features</h4><p style="margin:15px 0px;font-family:Helvetica,arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)" class="gmail_msg">Various drafts of this proposal have included additional features (decomposable key paths, prefix comparisons, support for custom <code style="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" class="gmail_msg">KeyPath</code> subclasses, creating a <code style="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" class="gmail_msg">KeyPath</code> from a <code style="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" class="gmail_msg">String</code> at runtime, <code style="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" class="gmail_msg">KeyPaths</code> conforming to <code style="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" class="gmail_msg">Codable</code>, bound key paths as a concrete type, etc.). We anticipate approaching these enhancements additively once the core <code style="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" class="gmail_msg"></code></p></div></div></div></blockquote></div></div></div></div>