|
1 |
| -- [Value and Type Parameter Packs](#value-and-type-parameter-packs) |
| 1 | +# Value and Type Parameter Packs |
| 2 | + |
| 3 | +* Proposal: [SE-NNNN](NNNN-parameter-packs.md) |
| 4 | +* Authors: [Holly Borla](https://github.com/swiftdev), [John McCall](https://github.com/swiftdev), [Slava Pestov]() |
| 5 | +* Review Manager: TBD |
| 6 | +* Status: **Awaiting implementation** |
| 7 | +* Implementation: On `main` gated behind the frontend flag `-enable-experimental-variadic-generics` |
| 8 | +* Review: ([pitch 1]()) ([pitch 2]()) |
| 9 | + |
| 10 | +## Contents |
| 11 | + |
2 | 12 | - [Proposed solution](#proposed-solution)
|
3 | 13 | - [Detailed design](#detailed-design)
|
4 | 14 | - [Type parameter packs](#type-parameter-packs)
|
|
32 | 42 | - [Tuple conformances](#tuple-conformances)
|
33 | 43 | - [Acknowledgments](#acknowledgments)
|
34 | 44 |
|
35 |
| -# Value and Type Parameter Packs |
| 45 | +## Introduction |
| 46 | + |
| 47 | +Many modern Swift libraries include ad-hoc variadic APIs with an arbitrary upper bound, typically achieved with overloads that each have a different fixed number of type parameters and corresponding arguments. Without variadic generic programming support in the language, these ad-hoc variadic APIs have a significant cost on library maintenance and the developer experience of using these APIs. |
| 48 | + |
| 49 | +This proposal adds _type parameter packs_ and _value parameter packs_ to enable abstracting over the number of types and values with distinct type. This is the first step toward variadic generics in Swift. |
| 50 | + |
| 51 | +## Motivation |
36 | 52 |
|
37 | 53 | Generic functions currently require a fixed number of type parameters. It is not possible to write a generic function that accepts an arbitrary number of arguments with distinct types, instead requiring one of the following workarounds:
|
38 | 54 |
|
@@ -759,4 +775,4 @@ extension<T...> (T...): Comparable where T: Comparable {
|
759 | 775 |
|
760 | 776 | ## Acknowledgments
|
761 | 777 |
|
762 |
| -Thank you to Robert Widmann for exploring the design space of modeling packs as tuples, to John McCall for his insight on the various possibilities in the variadic generics design space, and to everyone who participated in earlier design discussions about variadic generics in Swift. |
| 778 | +Thank you to Robert Widmann for exploring the design space of modeling packs as tuples, and to everyone who participated in earlier design discussions about variadic generics in Swift. |
0 commit comments