[swift-evolution] Removing Variadic Parameters.

Leonardo Pessoa me at lmpessoa.com
Wed Jul 6 13:55:28 CDT 2016


-1_000_000_000

I believe variadic parameters are useful in a range of situations and
I use them myself a lot. As you mentioned yourself, you never created
variadic functions and you are allowed to continue working like that
for as long as it suits you so. It is a choice and you and other
developers are allowed to decide when and where to use it. As for
trailing closures, just as Saagar mentioned, your variadic parameter
does not have to be the last one, as it has to in C, and thus they do
not compete. Give it a try.

L

On 6 July 2016 at 15:49, Saagar Jha via swift-evolution
<swift-evolution at swift.org> wrote:
>
>
> On Wed, Jul 6, 2016 at 11:38 AM Tino Heth via swift-evolution
> <swift-evolution at swift.org> wrote:
>>
>> It's a late answer… but I wanted to be a good citizen and checked if the
>> topic has been discussed before; so, it seems that is not the case ;-)
>>
>> In short, I agree:
>> Variadic parameters are somewhat cool, and I think I was exited when I've
>> seen them in C the first time… but I afair, I never created a variadic
>> function in production code, and I think I just used them for the first time
>> in Swift (I checked wether print is variadic…)
>> As of today, string interpolation has several advantages over old-style
>> string-formatting, and I can't remember any other method in one of the
>> established libraries that uses this feature:
>> Explicitly creating an array is just two additional characters, which
>> doesn't matter in a long list (which imho shouldn't be crammed into the
>> function call anyways), and when there are only a few parameters, you can
>> mimic variadics with Optionals defaulted to nil — and who knows what the
>> long-awaited hygienic macros might do to the importance of variadic
>> parameters.
>>
>> Additionally, variadic parameters compete with trailing closures, which
>> for me would always win the struggle for the last parameter ;-)
>
>
> Actually, you don’t have to make a variadic parameter last…print doesn’t.
>
>>
>>
>> As I said, I can't remember a single use case in Swift — and I already
>> utilized quite a lot of the "strange" techniques (currying, tuple splat,
>> complicated combinations of generics & protocols…).
>> So for me, the answer to the question "would I add this feature to Swift
>> if it wasn't there?" is a clear no…
>>
>> Tino
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
> --
> -Saagar Jha
>
> _______________________________________________
> 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