<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="">
I was also in favour of using an ellipsis operator to “unsplat” (to borrow the term in some other languages) an array into variadic parameters. However, after taking a look at Haravikk’s proposal [1] I think I would oppose using ellipsis for that purpose.
<div class=""><br class="">
</div>
<div class="">The main advantage I see is that this proposal enables future extensions to other kind of iterable collections (as shown in the “Proposed Extension” section). It'd break with “legacy” variadic features and would give Swift a more powerful feature
 to design APIs.<br class="">
<div class=""><br class="">
</div>
<div class="">[1]&nbsp;<a href="https://github.com/Haravikk/swift-evolution/blob/a13dc03d6a8c76b25a30710d70cbadc1eb31b3cd/proposals/nnnn-variadics-as-attribute.md" class="">https://github.com/Haravikk/swift-evolution/blob/a13dc03d6a8c76b25a30710d70cbadc1eb31b3cd/proposals/nnnn-variadics-as-attribute.md</a><br class="">
<div class=""><br class="">
</div>
<div class=""><br class="">
<div>
<blockquote type="cite" class="">
<div class="">On 27 Feb 2017, at 04:00, Derrick Ho 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="">
<div dir="ltr" class="">Well, I have found these discussions...
<div class=""><br class="">
</div>
<div class="">It was marked as a <a href="https://bugs.swift.org/browse/SR-128" class="">
bug</a> and then directed to <a href="https://github.com/ArtSabintsev/swift-evolution/blob/5ef676ec2616465c1cb854f82e3fd4e90b4b09c6/proposals/array-variadic-function.md" class="">
swift evolution</a>.</div>
<div class=""><br class="">
</div>
<div class="">@jose, the prefix operator you mention looks good, but in the past discussions they wanted a postfix operator so that it would match the declaration.&nbsp; I think I like the postfix operator.</div>
<div class=""><br class="">
</div>
<div class="">func foo(_ a: String...) {}</div>
<div class=""><br class="">
</div>
<div class="">foo([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]...) //&lt;- This looks clear.&nbsp; It is turning the array into a variadic argument.</div>
<div class=""><br class="">
</div>
<div class="">However, that thread was closed because it wasn't &quot;discussed&quot; enough prior making the pull request.</div>
<div class=""><br class="">
</div>
<div class="">therefore, if people want it, they got to cast their vote in here by either supporting it or opposing it.</div>
<div class=""><br class="">
</div>
<div class="">I like my original suggestion since it is more explicit.</div>
<div class=""><br class="">
</div>
<div class="">
<div class="">foo([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] as String...)&nbsp;</div>
<div class=""><br class="">
</div>
</div>
<div class=""><br class="">
</div>
</div>
<br class="">
<div class="gmail_quote">
<div dir="ltr" class="">On Sun, Feb 26, 2017 at 7:59 PM Jose Cheyo Jimenez &lt;<a href="mailto:cheyo@masters3d.com" class="">cheyo@masters3d.com</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">
<blockquote type="cite" class="gmail_msg">
<div class="gmail_msg">On Feb 26, 2017, at 8:26 AM, 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_-2241817684941310197Apple-interchange-newline">
<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([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;]) // &lt;-error</div>
<div class="gmail_msg">foo(&quot;a&quot;, &quot;b&quot;, &quot;c&quot;) // 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([&quot;a&quot;, &quot;b&quot;, &quot;c&quot;] as String...) // &lt;- error. &nbsp;doesn't consider String... to be a type.<br class="gmail_msg">
</div>
</div>
</div>
</blockquote>
<div class="gmail_msg"><br class="gmail_msg">
</div>
</div>
</div>
<div style="word-wrap:break-word" class="gmail_msg">
<div class="gmail_msg">
<div class="gmail_msg">I think this needs to be done with a spread operator in order to disambiguate.&nbsp;</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">foo(...[&quot;a&quot;, &quot;b&quot;, &quot;c”]&nbsp;</div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg"><a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator" class="gmail_msg" target="_blank">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Spread_operator</a></div>
<div class="gmail_msg"><br class="gmail_msg">
</div>
<div class="gmail_msg">I like the idea. Its syntactic sugar so I am not sure how open the core team would be to adding it.&nbsp;</div>
<br class="gmail_msg">
<blockquote type="cite" class="gmail_msg">
<div class="gmail_msg"></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">
<div dir="ltr" class="gmail_msg">
<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>
<br class="gmail_msg">
</div>
</blockquote>
</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="">
</div>
</div>
</div>
</body>
</html>