<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="">That’s correct, thanks for the correction. The rule only applies to parameters with argument labels.</div><div class=""><br class=""></div><div class="">But still, we’d lost this guarantee of self-documenting, type-safe non-emptiness if arbitrary arrays can be passed to variadic parameters with argument labels.</div><div class=""><br class=""></div><div class="">R+</div><br class=""><div><blockquote type="cite" class=""><div class="">On 8 Mar 2017, at 23:42, Derrick Ho &lt;<a href="mailto:wh1pch81n@gmail.com" class="">wh1pch81n@gmail.com</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class="">Rudolf, I don't believe that is a rule.<br class=""><br class="">One example includes NSLog()<br class=""><br class="">In which the first parameter is a format string and the second is a variadic argument.  The second one can be omitted.<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Wed, Mar 8, 2017 at 5:09 PM Rudolf Adamkovič via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; wrote:<br class=""></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" class="gmail_msg"><div class="gmail_msg">Correct me if I’m wrong but a variadic argument is guaranteed to have one or more elements in the array. Isn’t that the case? As an example, consider the following initializer:</div><div class="gmail_msg"><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo;min-height:15px" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"></span><br class="gmail_msg"></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">public</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#ba2da2" class="gmail_msg">init</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">(state: </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="gmail_msg">State</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">, actions: </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187" class="gmail_msg">Action</span><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">...) {</span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; &nbsp; &nbsp; <font color="#4f8187" class="gmail_msg">// ...</font></span></div><div style="margin:0px;font-size:13px;line-height:normal;font-family:Menlo" class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg">&nbsp; &nbsp; }</span></div></div><div class="gmail_msg"><span style="font-variant-ligatures:no-common-ligatures" class="gmail_msg"><br class="gmail_msg"></span></div><div class="gmail_msg">Here, I can count on&nbsp;<span style="font-family:Menlo;font-size:13px" class="gmail_msg">actions</span>&nbsp;to be a non-empty array. It’s self-documenting and type-safe. How would this work if arrays are (implicitly or explicitly) convertible to variadic arguments?</div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">R+</div><br class="gmail_msg"></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">On 26 Feb 2017, at 17:26, Derrick Ho via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="gmail_msg m_7403379559523347716Apple-interchange-newline"></blockquote></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><div dir="ltr" class="gmail_msg">In swift, a variadic argument can become an array without too much effort.<div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">func foo(_ va: String...) {</div><div class="gmail_msg">&nbsp; &nbsp;let a: [String] = va</div><div class="gmail_msg">}</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">However, it seems odd to me that an array can not be converted into a variadic argument</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">foo(["a", "b", "c"]) // &lt;-error</div><div class="gmail_msg">foo("a", "b", "c") // no error<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg"><a href="http://stackoverflow.com/questions/24024376/passing-an-array-to-a-function-with-variable-number-of-args-in-swift" class="gmail_msg" target="_blank">Other people have wondered about this too.</a><br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">According to&nbsp;<a href="https://devforums.apple.com/message/970958#970958" class="gmail_msg" target="_blank">this thread</a>&nbsp;Doug Gregor says it is due to some type ambiguity. with Generics.</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">If type ambiguity is the issue, Do we have the option to cast it to the correct type?</div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">foo(["a", "b", "c"] as String...) // &lt;- error. &nbsp;doesn't consider String... to be a type.<br class="gmail_msg"></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">What does the community think? Should we be granted some mechanism to turn an array into a variadic argument?</div></div></div></blockquote></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg">
_______________________________________________<br class="gmail_msg">swift-evolution mailing list<br class="gmail_msg"><a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg"><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg"></div></blockquote></div></div>_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>
</div></blockquote></div><br class=""></body></html>