[swift-evolution] [Idea] Passing an Array to Variadic Functions
Erica Sadun
erica at ericasadun.com
Mon Apr 18 14:06:42 CDT 2016
> On Apr 18, 2016, at 1:01 PM, Tony Allevato via swift-evolution <swift-evolution at swift.org> wrote:
>
> I would also be supportive of removing varargs for now, in favor of a rethought design when generics are completed.
>
> In their current form, varargs are fairly limited—because they're mapped onto an array, the argument types must be homogeneous, so either your function can only usefully take a single type of argument, or you potentially lose information because they have to be upcast to a common supertype or Any in order to build the array.
>
> I'm not convinced that varargs produce code that is much cleaner than the array version. Is this:
>
> String(format: "%@ is %d years old", name, age)
>
> that much cleaner than:
>
> String(format: "%@ is %d years old", arguments: [name, age])
I would like to see format strings go away and be replace with safer inline annotations.
-- E, somewhat agnostic on variadics
More information about the swift-evolution
mailing list