<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Apr 14, 2016, at 8:23 PM, Andrey Tarantsov via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Hey, Milos!<div class=""><br class=""></div><div class="">Can you please give us a few real-world examples where initializing a nontrivial tree-like data structure in code would be useful?</div><div class=""><br class=""></div><div class="">It's an honest question — I have never felt the need in my life, and I always preferred to move the data into something like a bundled json or CSV, rather than providing it in code.</div><div class=""><br class=""></div><div class="">A.</div><div class=""><br class=""></div></div></div></blockquote><div><br class=""></div><div><br class=""></div><div>ditto.&nbsp;</div><div>This is where in the simplest case I write a simple text(json) file, and in the more extreme cases, write a custom DSL+Eclipse Editor to deal with a complete custom file format (I said extreme.. but I did do it). I would even go further.. I’d rather the language do NOT make it easy to have complex literals initializations to avoid having to chase critical CONFIG elements in the source code. D has an interesting concept if you REALLY want do data in code: import (“data_in_code.d”)&nbsp;</div><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Apr 14, 2016, at 10:27 PM, Milos Rankovic via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">In Swift, we cannot compile:<div class=""><font face="Menlo" size="2" class=""><br class=""></font></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">_</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;= [[],&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]]]</span></font></div></div></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" size="2" class=""><br class=""></font></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">The reason for the compile-time error is that we are not in fact creating an array, but a tree – a more general structure of which arrays are only a special case. Given the well-deserved and growing reputation of Swift, one would hope that in this instance the compiler would be able to default to something like a:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" size="2" class=""><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">enum</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;Tree&lt;Value&gt; {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;Leaf(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;Branches([</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">])</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font class="">}</font></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal; color: rgb(73, 162, 210);"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">extension</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">ArrayLiteralConvertible</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;{</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">init</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(arrayLiteral elements:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">...) {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">self</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;= .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Branches</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(elements)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font class="">}</font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></font></div></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">For this to work in the playground, however, we must manually lift the values into the world of trees first. And to make that chore in turn easier on the eye we can introduce a:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><div class="" style="margin: 0px; line-height: normal; color: rgb(203, 203, 203);"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">prefix</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">operator</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;◊ {}&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">// looks a bit like a leaf (us/uk kbd:&nbsp;</span><span class="" style="line-height: normal; font-variant-ligatures: no-common-ligatures;"><b class="">⎇⇧</b></span><span class="" style="font-variant-ligatures: no-common-ligatures;">V)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">prefix</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;◊ &lt;T&gt; (leaf:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt; {&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Leaf</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(leaf) }</span></font></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font class=""><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;tree:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt; = [[],&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]]]</span></font></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div></font></span></div><div class="">The point here is that if adding such a fundamental type to the Standard Library would not be a priority at present, it is not the end of the world since we can easily enough write it ourselves… What we cannot do ourselves, however, is to get rid of the need for that operator in the common scenario of initialising with literal values. For this we need a literal-convertible protocol requiring&nbsp;<b class="">two</b>&nbsp;initialisers:</div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><div style="margin: 0px; line-height: normal;" class=""><font face="Menlo" size="2" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);" class="">protocol</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;</span><span style="color: rgb(73, 162, 210);" class="">TreeLiteralConvertible</span>&nbsp;{</div><div style="margin: 0px; line-height: normal; color: rgb(200, 172, 229);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">associatedtype</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> LeafValue</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.LeafValue...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></font></div></div></div></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">Then we could simply:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;tree:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Tree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt; = [[],&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">1</span><span class="" style="font-variant-ligatures: no-common-ligatures;">, [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">2</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">3</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [[</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">4</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">5</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">6</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">7</span><span class="" style="font-variant-ligatures: no-common-ligatures;">], [</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">8</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">9</span><span class="" style="font-variant-ligatures: no-common-ligatures;">]]]</span></font></div></div></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">And, whilst we are at it, we could also get rid of the need for that operator in the case of nested associative arrays (again, you can try this in the playground):</span></div><div class=""><font face="Menlo" size="2" class=""><br class=""></font></div><div class=""><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">enum</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;<span style="color: rgb(73, 162, 210);" class="">DictionaryTree</span>&lt;Key, Value&gt; {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;Leaf(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">case</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;Branches([(</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Key</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)])</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2">}</font></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal; color: rgb(73, 162, 210);"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">extension</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">DictionaryLiteralConvertible</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;{</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">init</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(dictionaryLiteral pairs: (</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Key</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">)...) {</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">self</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;= .</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Branches</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(pairs)</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2"><span class="Apple-tab-span" style="white-space: pre;">        </span>}</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2">}</font></span></div><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">prefix</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">func</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;◊ &lt;Key, Value&gt; (leaf:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">) -&gt;&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Key</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Value</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt; {&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">return</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;.</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(73, 162, 210);">Leaf</span><span class="" style="font-variant-ligatures: no-common-ligatures;">(leaf) }</span></font></div></div><div class=""><div class="" style="margin: 0px; line-height: normal; min-height: 17px;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"></span><br class=""></font></div><div class="" style="margin: 0px; line-height: normal; color: rgb(73, 162, 210);"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);">let</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;map:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">DictionaryTree</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures;">String</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span><span class="" style="font-variant-ligatures: no-common-ligatures;">Int</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt; = [</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"A"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;: [:],</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"B"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;: [</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Ba"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bb"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;: [</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc1"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc2"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span><span class="" style="font-variant-ligatures: no-common-ligatures;">,</span></font></div><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" class="" size="2"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">                        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(100, 150, 29);">"Bc3"</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&nbsp;:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(145, 84, 15);">◊</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(255, 38, 0);">0</span></font></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2"><span class="Apple-tab-span" style="white-space: pre;">                </span>]</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2"><span class="Apple-tab-span" style="white-space: pre;">        </span>]</font></span></div><div class="" style="margin: 0px; line-height: normal;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" class="" size="2">]</font></span></div></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">… by introducing an analogous protocol:</span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><font face="Menlo" size="2" class=""><br class=""></font></span></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><div class="" style="margin: 0px; line-height: normal;"><font face="Menlo" size="2" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(200, 172, 229);" class="">protocol</span><span style="font-variant-ligatures: no-common-ligatures;" class="">&nbsp;<span style="color: rgb(73, 162, 210);" class="">DictionaryTreeLiteralConvertible</span>&nbsp;{</span></div><div style="margin: 0px; line-height: normal; color: rgb(200, 172, 229);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">associatedtype</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> Key</span></div><div style="margin: 0px; line-height: normal; color: rgb(200, 172, 229);" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures" class="">associatedtype</span><span style="font-variant-ligatures: no-common-ligatures;" class=""> LeafValue</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">.LeafValue...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><span class="Apple-tab-span" style="white-space:pre">        </span></span><span style="font-variant-ligatures: no-common-ligatures; color: #c8ace5" class="">init</span><span style="font-variant-ligatures: no-common-ligatures" class="">(literal: (Key, </span><span style="font-variant-ligatures: no-common-ligatures; color: #49a2d2" class="">Self</span><span style="font-variant-ligatures: no-common-ligatures" class="">)...)</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures" class=""><br class=""></span></div></font></div></span></div><div class="">Please note: I do understand that fleshing out these structures (along with all the juicy methods, operators and lazy alternatives) may not currently be a priority for Swift. The two literal-convertible protocols however, may be a much less daunting task, which would open to us some very useful programming idioms…</div><div class=""><br class=""></div><div class=""><span class="" style="font-variant-ligatures: no-common-ligatures;">milos</span></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></blockquote></div><br class=""></body></html>