[swift-evolution] [pitch] Variadic Arguments should accept Arrays

Haravikk swift-evolution at haravikk.me
Mon Feb 27 14:55:21 CST 2017


> On 27 Feb 2017, at 19:09, Jose Cheyo Jimenez <cheyo at masters3d.com> wrote:
> 
>> 
>> On Feb 27, 2017, at 9:59 AM, Haravikk <swift-evolution at haravikk.me <mailto:swift-evolution at haravikk.me>> wrote:
>> 
>> 
>>> On 27 Feb 2017, at 17:10, Jose Cheyo Jimenez via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> On Feb 26, 2017, at 9:25 AM, Tino Heth via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>> 
>>>> I suggest to take a look at the topics "Variadics as an Attribute" and "array splatting for variadic parameters" and https://github.com/Haravikk/swift-evolution/blob/a13dc03d6a8c76b25a30710d70cbadc1eb31b3cd/proposals/nnnn-variadics-as-attribute.md <https://github.com/Haravikk/swift-evolution/blob/a13dc03d6a8c76b25a30710d70cbadc1eb31b3cd/proposals/nnnn-variadics-as-attribute.md>.
>>>> 
>>>> This is basically the other way round (arrays would accept variadic arguments), but it has the same effect — and more:
>>>> You get rid of the odd "…" type, and it's also possible to use this with types besides array (set, iterator….)
>>> I agree with getting rid of the Type... because we could use ... in slicing (see String manifesto). Why must it be an attribute and not just "*" ? The advantage I see is that this will play great in also deconstructing collection like things like Array, Slice and Tuple. This is already familiar to python and ruby users. 
>> 
>> Part of the aim is to avoid less easily discovered custom syntax; the point of the proposal is that there's no need for a special syntax just to support variadics as attributes already exist, plus they're more descriptive about what they do and easy to look-up.
> 
> 
> These is very unfortunate as a solution for “spreading” a collection or tuple so that It can be applied to function taking a variadic.
> It makes sense on the declaration site but not on the call site. 
> 
> someFunc(@nonVariadic [1])  
> someFunc(@variadic [1]) 

These are only required in the case that a function accepts arguments of type Any; since both the array itself, and its contents are valid example of Any. This isn't the case if the variadic is on any other type.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20170227/b1dae98e/attachment.html>


More information about the swift-evolution mailing list