<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">Le 9 janv. 2018 à 08:06, Gwendal Roué via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</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=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 9 janv. 2018 à 06:40, Nevin Brackett-Rozinsky via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">The ulterior question of whether preserving “DictionaryLiteral”&nbsp;is worthwhile, is apparently out of scope. Personally, I have a hard time imagining a compelling use-case outside of the standard library, and I doubt it’s being used “in the wild” (I checked several projects in the source-compatibility suite and found zero occurrences).</div></div></div></div></div></blockquote><br class=""></div><div class="">DictionaryLiteral is worthwhile. The SQLite library GRDB uses DictionaryLiteral in order to build database rows (which may have duplicated column names, and whose column ordering is important). This is mostly useful for tests:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp;&nbsp;<span style="color: #ba2da2" class="">let</span> row = <span style="color: #ba2da2" class="">try</span> Row.fetchOne(db, <span style="color: #d12f1b" class="">"SELECT 1 AS a, 2 AS a"</span>)!</div><div style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);" class="">&nbsp; &nbsp; XCTAssertEqual(row, [<span style="color: #d12f1b" class="">"a"</span>: <span style="color: #272ad8" class="">1</span>, <span style="color: #d12f1b" class="">"a"</span>: <span style="color: #272ad8" class="">2</span>])</div><div class=""><br class=""></div></div>Gwendal</div></div></blockquote><br class=""></div><div>Chris Lattner's wrote:</div><div><br class=""></div><div><div style="font-family: SFUIDisplay-Regular;" class=""><blockquote type="cite" class="">why is maintaining duplicate keys a feature?</blockquote></div><div class=""><blockquote type="cite" class=""><span style="font-family: SFUIDisplay-Regular;" class="">Since it is immutable, why not sort the keys in the initializer, allowing an efficient binary search to look up values?</span></blockquote></div></div><br class=""><div class="">I really wish both duplicated keys and key ordering would be preserved, since both are needed for the above sample code.</div><div class=""><br class=""></div><div class="">Should those features be lost, the sky wouldn't fall, that's sure. But we'd have to write something much less easy to wrote and read:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">XCTAssertEqual(row.map { $0 }, [(</span><span class="" style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255); color: rgb(209, 47, 27);">"a"</span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">,</span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">&nbsp;</span><span class="" style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255); color: rgb(39, 42, 216);">1)</span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">,</span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">&nbsp;(</span><span class="" style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255); color: rgb(209, 47, 27);">"a"</span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">,</span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">&nbsp;</span><span class="" style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255); color: rgb(39, 42, 216);">2)</span><span style="font-family: Menlo; font-size: 12px; background-color: rgb(255, 255, 255);" class="">])</span></div><div><br class=""></div><div>Gwendal</div><div><br class=""></div></body></html>