Search code examples
swiftgenericsvariadicparameter-pack

Variadic Generics vs. Value and Type Parameter Packs in Swift


There are two evolution proposals: Variadic Generics and Value and Type Parameter Packs.
So... what is the difference? They feel conceptually very similar.
The second one, with super heavy syntax, is already implemented in Swift 5.9
The first one... I'm not sure. Is the Type Parameter Packs is just a final version of initial Variadic Generic proposal? Can't find any explicit info.


Solution

  • "Variadic Generics" proposes a few more features than what is implemented in Swift 5.9, like iterating over parameter packs.

    The "Variadic Generics" Swift Forums thread links to the pull request #1510, which is closed. It is said there, that #1510 has been superseded by #1839. #1839 is also closed, after the comment:

    I think the essence of this document will be reviewed under the parameter packs proposal, and the rest will be pitched as individual features building on parameter packs (should they be accepted).

    And the "parameter packs proposal" mentioned here is the proposal that is implemented in 5.9. "The rest" are split into several different proposal - some of them are implemented in 5.9 (variadic generic types, expansion to tuples), some of them are not (pack iteration).

    In short, the variadic generics pitch came first, then split into multiple proposals, one of which is parameter packs.