<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><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">
<div class=""><font face="Consolas" class="">func f(_ args: [Int]) {</font></div>
<div class=""><font face="Consolas" class=""> // Some implementation ...</font></div>
<div class=""><font face="Consolas" class="">}</font></div>
<div class=""><font face="Consolas" class=""><br class="">
</font></div>
<div class=""><font face="Consolas" class="">func f(_ args: Int…) {</font></div>
<div class=""><font face="Consolas" class=""> f(args)</font></div>
<div class=""><font face="Consolas" class="">}</font></div>
<div class=""><br class="">
</div>
<div class="">Some people also advocate (myself generally included) that one should prefer the signature explicitly marking <font face="Consolas" class="">args</font> as an array, as the syntactic overhead of wrapping the arguments with “<font face="Consolas" class="">[]</font>”
when calling <font face="Consolas" class="">f</font> is arguably bearable. However, in some other situations, this approach might not be applicable. For instance, one may simply not be able to modify the original function. Another use-case may be a function
that should forward its own variadic parameters.</div></div></div></blockquote></div><div><br class=""></div>There has been a proposal that would not only solve this issue, but also add a lot flexibility while simplifying the language at the same time:<div class=""><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></div><div class=""><br class=""></div><div class="">Imho it's one of the best ideas I have seen on evolution, and definitely the most valuable segregation of C legacy.</div><div class="">Sadly, it was discussed in a very busy timeframe, and I think it really didn't receive the attention it deserves…</div><div class=""><br class=""></div><div class="">I would have asked Haravikk wether he would like to start a second try anyways, and as this topic is directly related, it's a good motivation to do so.</div><div class=""><br class=""></div><div class="">The basic idea of the proposal is to get rid of "…"-magic and declare variadic parameters with their natural type (Array<T> — but one aspect of this idea is that it can be extended easily to work with sets and other types that can be expressed with an array literal).</div></body></html>