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

Gwendal Roué gwendal.roue at gmail.com
Mon Apr 18 02:48:02 CDT 2016

> Le 18 avr. 2016 à 09:35, Dennis Weissmann via swift-evolution <swift-evolution at swift.org> a écrit :
>> Why not remove varargs altogether from Swift, it is easy enough to put [] round a list?
> +1, that was my thought too. I can’t think of a use case where you can’t use an array instead of varargs (this assumes all vararg parameters are converted to array parameters).

Oh no please no. Of course a variadic function can always be rewritten as a function that takes an array. Of course. You always can use an array. Got it. But some APIs are nicer with varargs. And even nicer APIs go over the top by adding support for arrays too, because not all lists are known at compile time. It’s a matter of being sensible.

	DatabaseTable.select(id, name).order(name, id)		// What’s the problem?
	// vs.
	DatabaseTable.select([id, name]).order([name, id])	// OK, of course... But some people will find it a litle short

Gwendal Roué

More information about the swift-evolution mailing list