[swift-evolution] [Idea] Passing an Array to Variadic Functions

Erica Sadun erica at ericasadun.com
Mon Apr 18 14:27:14 CDT 2016


This is why god gave us bike sheds.

Maybe "My earned interest rate this year is \({02.2}theRate)%!"

-- E


> On Apr 18, 2016, at 1:23 PM, Ricardo Parada <rparada at mac.com> wrote:
> 
> What would that look like?
> 
> 
> 
>> On Apr 18, 2016, at 3:06 PM, Erica Sadun via swift-evolution <swift-evolution at swift.org> wrote:
>> 
>> 
>>> 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
>> 
>> 
>> 
>> _______________________________________________
>> 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