[swift-evolution] [Idea] Passing an Array to Variadic Functions
Ricardo Parada
rparada at mac.com
Tue Apr 19 18:07:16 CDT 2016
Would that require some compiler magic, i.e.
foo(#splat(arr))
> On Apr 19, 2016, at 12:51 PM, Vladimir.S via swift-evolution <swift-evolution at swift.org> wrote:
>
> I suggest to look at the subject of this thread and initial proposal:
> "Swift should allow passing an *array to variadic functions*, or we should implement a type-safe `apply()` function in the standard library."
>
> I.e. the question is *if we want/need to be able to pass array to existed variadic function*. Not about removing the variadic feature("removing" is offtop for this poposal, as I understand)
>
> For example we have:
> func foo(x: Int ...) {..}
>
> and later in code we have
> var arr : [Int] = getSomehow()
>
> Should we be able to call foo in this way:
>
> foo(arr)
>
> Or how we can call foo(..) about array of values, not values as list of parameters.
>
>
>> On 19.04.2016 19:34, Jeremy Pereira via swift-evolution wrote:
>>
>>> On 19 Apr 2016, at 07:51, Haravikk via swift-evolution <swift-evolution at swift.org> wrote:
>>>
>>>
>>>
>>> I think the question really is whether not having to add square brackets is really enough to justify a whole language feature? Basically you’ve got two ways you could do this:
>>
>> No, that’s not the question. The question is whether the downside to variadic parameters is really enough to justify _removing_ an existing language feature.
>>
>> The burden of justification should be on those people wanting to change the language, not on those wanting to maintain the status quo and “I don’t like it” or “I think it makes code a tiny bit less readable” is not sufficient justification, in my opinion because you already have the option not to use the feature. Whereas, if you remove the feature, those people of the opinion “it makes code a tiny bit more readable” have nowhere to go.
>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list