<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 à 17:16, Zach Waldowski 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 style="font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: Arial;" class="">I'm not sure a valid use case by a third party makes it hold its weight for inclusion in the stdlib.</div></div></blockquote><div><br class=""></div><div>You're definitely right, and that's why I wrote with the most humble tone I could.</div><div><br class=""></div><div>Yet, the design of the stdlib *requires* some speculation about use cases, and speculation is *helped* by the exposition of actual uses. I'm not sure readers of the mailing list had any idea of the use cases of the current DictionaryLiteral, and maybe I helped a little.</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: Arial;" class="">Reproducing its feature set is extremely trivial, and would probably allow you to hint the implementation details better for your use case.<br class=""></div></div></blockquote><div><br class=""></div><div>Please define "trivial".</div><div><br class=""></div><div>In case anybody would wonder, in the line below the `row` variable is of type Row which happens to adopt ExpressibleByDictionaryLiteral. It is not of type DictionaryLiteral. The use case here is the ability to express a row with a dictionary literal that accepts duplicated keys and preserves ordering:</div><div><br class=""></div><div><div class=""><div class=""><div class="" style="word-wrap: break-word;"><div class=""><div class="" style="margin: 0px; font-size: 12px; line-height: normal; font-family: Menlo; background-color: rgb(255, 255, 255);"><span class="Apple-tab-span" style="white-space: pre;">        </span>XCTAssertEqual(row, [<span class="colour" style="color: rgb(209, 47, 27);">"a"</span>:&nbsp;<span class="colour" style="color: rgb(39, 42, 216);">1</span>,&nbsp;<span class="colour" style="color: rgb(209, 47, 27);">"a"</span>:&nbsp;<span class="colour" style="color: rgb(39, 42, 216);">2</span>])</div></div></div></div></div></div><div><br class=""></div><div>I don't see how anything could better fit this use case than the current DictionaryLiteral. This is not *my* use case, but the use case of anyone that wants to model database rows beyond the traditional (and ill-advised) dictionary.</div><div><br class=""></div><div>Some other users may come with other use cases that may also help the stdlib designers choose the best solution.</div><div><br class=""></div><div>Gwendal</div><br class=""><blockquote type="cite" class=""><div class=""><div style="font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: Arial;" class=""><br class=""></div><div id="sig20055365" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><div class="signature"><span class="font" style="font-family: arial, sans-serif, sans-serif;">Zach</span><span class="font" style="font-family: arial, sans-serif, sans-serif;"></span><br class=""></div><div class="signature"><a href="mailto:zach@waldowski.me" class=""><span class="font" style="font-family: arial, sans-serif, sans-serif;">zach@waldowski.me</span></a><span class="font" style="font-family: arial, sans-serif, sans-serif;"></span><br class=""></div><div class="signature"><br class=""></div><div style="font-family: Arial;" class=""><br class=""></div></div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">On Tue, Jan 9, 2018, at 2:12 AM, Gwendal Roué via swift-evolution wrote:<br class=""></div><blockquote type="cite" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class=""><div style="font-family: Arial;" class=""><br class=""></div><div class=""><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 :<br class=""></div><div style="font-family: Arial;" class=""><br class=""></div><div class=""><div style="word-wrap: break-word;" class=""><div style="font-family: Arial;" class=""><br class=""></div><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 :<br class=""></div><div style="font-family: Arial;" class=""><br class=""></div><div class=""><div dir="ltr" class=""><div class=""><div defang_data-gmailquote="yes" class=""><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).<br class=""></div></div></div></div></div></blockquote><div style="font-family: Arial;" class=""><br class=""></div></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:<br class=""></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 class="colour" style="color: rgb(186, 45, 162);">let</span><span class="Apple-converted-space">&nbsp;</span>row =<span class="Apple-converted-space">&nbsp;</span><span class="colour" style="color: rgb(186, 45, 162);">try</span><span class="Apple-converted-space">&nbsp;</span>Row.fetchOne(db,<span class="Apple-converted-space">&nbsp;</span><span class="colour" style="color: rgb(209, 47, 27);">"SELECT 1 AS a, 2 AS a"</span>)!<br class=""></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 class="colour" style="color: rgb(209, 47, 27);">"a"</span>:<span class="Apple-converted-space">&nbsp;</span><span class="colour" style="color: rgb(39, 42, 216);">1</span>,<span class="Apple-converted-space">&nbsp;</span><span class="colour" style="color: rgb(209, 47, 27);">"a"</span>:<span class="Apple-converted-space">&nbsp;</span><span class="colour" style="color: rgb(39, 42, 216);">2</span>])<br class=""></div><div class=""><br class=""></div></div><div style="font-family: Arial;" class="">Gwendal<br class=""></div></div></div></blockquote><div style="font-family: Arial;" class=""><br class=""></div></div><div class="">Chris Lattner's wrote:<br class=""></div><div class=""><br class=""></div><div class=""><div style="font-family: SFUIDisplay-Regular;" class=""><blockquote type="cite" class="">why is maintaining duplicate keys a feature?<br class=""></blockquote></div><div class=""><blockquote type="cite" class=""><span class="font" style="font-family: SFUIDisplay-Regular;">Since it is immutable, why not sort the keys in the initializer, allowing an efficient binary search to look up values?</span><br class=""></blockquote></div></div><div style="font-family: Arial;" class=""><br class=""></div><div class="">I really wish both duplicated keys and key ordering would be preserved, since both are needed for the above sample code.<br class=""></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:<br class=""></div><div class=""><br class=""></div><div class=""><span style="white-space: pre;" class=""></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">XCTAssertEqual(row.map { $0 }, [(</span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="colour" style="color: rgb(209, 47, 27);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">"a"</span></span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">,</span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">&nbsp;</span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="colour" style="color: rgb(39, 42, 216);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">1)</span></span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">,</span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">&nbsp;(</span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="colour" style="color: rgb(209, 47, 27);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">"a"</span></span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">,</span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">&nbsp;</span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="colour" style="color: rgb(39, 42, 216);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">2)</span></span></span></span><span class="highlight" style="background-color: rgb(255, 255, 255);"><span class="font" style="font-family: Menlo;"><span class="size" style="font-size: 12px;">])</span></span></span><br class=""></div><div class=""><br class=""></div><div class="">Gwendal<br class=""></div><div class=""><br class=""></div><div class=""><u class="">_______________________________________________</u><br class=""></div><div class="">swift-evolution mailing list<br class=""></div><div class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""></div><div 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 style="font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: Arial;" class=""><br class=""></div><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></body></html>