-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Value and type parameter packs. #1956
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tried to give it a good go of pre-review. Hopefully the comments are helpful although the main things you've already flagged as to-dos.
proposals/NNNN-parameter-packs.md
Outdated
* There are two very different models for working with packs; the same conceptual expansion has very different spellings at the type and value level, `repeat Wrapped<each T>` vs `values.map { Wrapped($0) }`. | ||
* Magic map can only be applied to one pack at a time, leaving no clear way to zip packs without adding other builtins. A `zip` builtin would also be misleading, because expanding two packs in parallel does not need to iterate over the packs twice, but using `zip(t, u).map { ... }` looks that way. | ||
* The closure-like syntax is misleading because it’s not a normal closure that you can write in the language. This operation is also very complex over packs with any structure, including concrete types, because the compiler either needs to infer a common generic signature for the closure that works for all elements, or it needs to separately type check the closure once for each element type. | ||
* `map` would still need to be resolved via overload resolution amongst the existing overloads, so this approach doesn't help much with the type checking issues that `...` has. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Possibly slot the alternatives to the decisions made for the "open questions" mentioned above down here.
Co-authored-by: Remy Demarest <[email protected]>
0bc5694
to
5a6c08e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Drive-by review with some apparent typos and other drafting suggestions.
proposals/NNNN-parameter-packs.md
Outdated
- Substituting `each T := {Int}` into `(repeat each T)`. | ||
- Substituting `each T := {}` into `(Int, repeat each T)`. | ||
|
||
Though unwrapping single-element tuples complicates type matching, surfacing single-element tuples in the programming model would icnrease the surface area of the language. One-element tuples would need to be manually unrwapped with `.0` or pattern matching in order to make use of their contents. This unwrapping would clutter up code. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: icnrease
Forum pitches:
With a dedicated syntax discussion at:
I originally wrote a prospective vision for variadic generics, but it turned out to be more like an extended future directions writeup, and much of the content has been folded into this pitch.