<div dir="ltr">I&#39;d call it an antipattern: it pretty much defeats the purpose of having the ExpressibleBy*Literal protocols.<div><br></div><div>If you just want a type to be constructible from a value of some other type (literal or not), that&#39;s what regular initializers are for. For example, in addition to its ArrayLiteralConvertible conformance, Set provides init&lt;S: Sequence where S.Iterator.Element == Element&gt;(_ seq: S), so you can write Set([1, 2, 3]). The literal protocols are different because they&#39;re invoked *implicitly*: doSomethingWithASet([1, 2, 3]).</div><div><br></div><div>They&#39;re also awkward, because the argument labels (integerLiteral:, arrayLiteral:, nilLiteral:) provide only type information, and not &quot;role&quot; information — and if you&#39;re invoking one of these inits explicitly, there&#39;s no way the compiler can enforce that you&#39;re actually passing a *literal* in for those parameters (in fact, you *can&#39;t* pass an array literal to init(arrayLiteral:), because it&#39;s a variadic parameter rather than an array parameter).</div><div class="gmail_extra"><br clear="all"><div><div class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div>Jacob<br></div></div></div></div>
<br><div class="gmail_quote">On Mon, Jul 11, 2016 at 5:22 PM, David Sweeris <span dir="ltr">&lt;<a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="auto"><span class=""><div><blockquote type="cite">On Jul 11, 2016, at 19:13, Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</blockquote></div><div><br></div></span><blockquote type="cite"><div dir="ltr"><span class=""><div>I&#39;d be happy with a warning + fix-it too.</div><div><br></div></span><span class=""><div><div class="gmail_extra"><div class="gmail_quote">On Mon, Jul 11, 2016 at 5:05 PM, Xiaodi Wu <span dir="ltr">&lt;<a href="mailto:xiaodi.wu@gmail.com" target="_blank">xiaodi.wu@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Maybe just a warning + fix-it would be sufficient?<div><br><div class="gmail_quote"><div dir="ltr">On Mon, Jul 11, 2016 at 19:02 Jacob Bandes-Storch via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">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 dir="ltr">Tangential: Is there any way to make it impossible to call these literal-initializers explicitly, instead requiring &quot;&lt;literal&gt; as T&quot; or just &quot;&lt;literal&gt;&quot; in a typed context?<div><br></div><div>I have seen several explicit calls of these initializers where literals would have been more appropriate, such as &quot;Set(arrayLiteral: foo, bar)&quot;, and I think this only happens because folks find these initializers via code completion. I can&#39;t think of any reason why you&#39;d want to invoke one by name rather than by using a literal.</div></div></blockquote></div></div></blockquote></div></div></div></span></div></blockquote><br><div>I don&#39;t see how this is a problem.</div><div><br></div><div>- Dave Sweeris</div></div></blockquote></div><br></div></div>