Another attempt at passing arrays as varargs (with implementation)

Given @dabrahams's feedback, specifically:

It seems as if the ... operator should be given another look. Reading through the Variadic Generics section in the Generics Manifesto and the ... operator is called out specifically as a possible spelling for the feature.

Variadic generics would allow us to abstract over a set of generic parameters. The syntax below is hopelessly influenced by C++11 variadic templates (sorry), where putting an ellipsis ("...") to the left of a declaration makes it a "parameter pack" containing zero or more parameters and putting an ellipsis to the right of a type/expression/etc. expands the parameter packs within that type/expression into separate arguments. The important part is that we be able to meaningfully abstract over zero or more generic parameters...

It places the ... operator before the type name, which falls out of alignment with the direction things were going in this thread. But! I came across this comment by Douglas later showing some preference to ... as a suffix:

I think this is fuel enough to reconsider the spelling of this pitch's feature. The ...operator (as a suffix) seems like a great way to package up all of Swift's variadic features.

3 Likes