[swift-evolution] Variadic generics discussion

Brent Royal-Gordon brent at architechies.com
Wed Jun 1 08:39:28 CDT 2016


> Perhaps inout params of type T could be somehow passed as a pair (T, (T) -> ()), where the first item is the input value and the second item is a writeback function representing the 'out' part of inout.

The simplest solution, I think, is to require the entire splatted tuple to be `inout` if any of the parameters it's being splatted into are `inout`. This doesn't give you the same granularity as the original, but I don't see that as a serious problem.

> I've no ideas for default values.

Ignoring the defaults is not a terrible solution. Leaving that aside, we could match the tuple against the parameter list, figure out (from positions and types) which parameters are missing, and fill in their default values. Or we could punt this to the overload selection layer, and make it so that writing, say, `print(_:)` implicitly creates a closure which always uses the default values for the `separator` and `terminator` parameters.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list