Skip to content

Commit b2ea985

Browse files
hborlaPsychoH13
andcommitted
Update proposals/NNNN-parameter-packs.md
Co-authored-by: Remy Demarest <[email protected]>
1 parent 09e11cf commit b2ea985

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

proposals/NNNN-parameter-packs.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,11 @@ let pairs = makePairs(firsts: 1, "hello" seconds: true, 1.0)
123123
// 'pairs' is '(Pair(1, true), Pair("hello", 2.0))'
124124
```
125125

126-
The `makrPairs` function declares two type parameter packs, `First` and `Second`. The value parameter packs `first` and `second` have the pack expansion types `repeat each First` and `repeat each Second`, respectively. The return type `(repeat Pair<each First, each Second>)` is a tuple type where each element is a `Pair` of elements from the `First` and `Second` parameter packs at the given tuple position.
126+
The `makePairs` function declares two type parameter packs, `First` and `Second`. The value parameter packs `first` and `second` have the pack expansion types `repeat each First` and `repeat each Second`, respectively. The return type `(repeat Pair<each First, each Second>)` is a tuple type where each element is a `Pair` of elements from the `First` and `Second` parameter packs at the given tuple position.
127127

128128
Inside the body of `makePairs()`, `repeat Pair(each first, each second)` is a pack expansion expression referencing the value parameter packs `first` and `second`.
129129

130-
The call to `makrPairs()` substitutes the type pack `{Int, Bool}` for `First`, and the type pack `{String, Double}` for `Second`. These substitutions are deduced by the _type matching rules_, described below. The function is called with four arguments; `first` is the value pack `{1, "hello"}`, and `second` is the value pack `{true, 2.0}`.
130+
The call to `makePairs()` substitutes the type pack `{Int, Bool}` for `First`, and the type pack `{String, Double}` for `Second`. These substitutions are deduced by the _type matching rules_, described below. The function is called with four arguments; `first` is the value pack `{1, "hello"}`, and `second` is the value pack `{true, 2.0}`.
131131

132132
The substituted return type is the tuple type with two elements `(Pair<Int, Bool>, Pair<String, Double>)`, and the returned value is the tuple value with two elements `(Pair(1, true), Pair("hello", 2.0))`.
133133

@@ -148,7 +148,7 @@ When referenced from type context, this identifier resolves to a _type parameter
148148
* The base type of a member type parameter pack, which is again subject to these rules
149149
* The pattern type of a pack expansion type, where it stands for the corresponding scalar element type
150150
* The pattern expression of a pack expansion expression, where it stands for the metatype of the corresponding scalar element type and can be used like any other scalar metatype, e.g. to call a static method, call an initializer, or reify the metatype value
151-
* The subject type of a conformance, superclass, layout or same-type requirement
151+
* The subject type of a conformance, superclass, layout, or same-type requirement
152152
* The constraint type of a same-type requirement
153153

154154
### Pack expansion type
@@ -388,7 +388,7 @@ All existing kinds of generic requirements generalize to type parameter packs. S
388388

389389
A valid substitution for the above might replace `S` with `{Array<Int>, Set<String>}`, and `T` with `{Int, String}`.
390390

391-
3. A same-type requirement where one side is a type parameter pack and the other side is a concrete type capturing at least one type parameter pack is interpreted as expanding the concrete type and constraining each element of the replacement type pack to the concrete element type:
391+
4. A same-type requirement where one side is a type parameter pack and the other side is a concrete type capturing at least one type parameter pack is interpreted as expanding the concrete type and constraining each element of the replacement type pack to the concrete element type:
392392

393393
```swift
394394
func variadic<each S: Sequence, each T>(_: repeat each S) where (each S).Element == Array<each T> {}
@@ -398,7 +398,7 @@ All existing kinds of generic requirements generalize to type parameter packs. S
398398

399399
A valid substitution for the above might replace `S` with `{Array<Array<Int>>, Set<Array<String>>}`, and `T` with `{Int, String}`.
400400

401-
3. A same-type requirement where both sides are type parameter packs constrains the elements of the replacement type pack element-wise:
401+
5. A same-type requirement where both sides are type parameter packs constrains the elements of the replacement type pack element-wise:
402402

403403
```swift
404404
func append<each S: Sequence, each T: Sequence>(_: repeat each S, _: repeat each T) where (each T).Element == (each S).Element {}
@@ -463,7 +463,7 @@ The type annotation of `tup` contains a pack expansion type `repeat (each T, eac
463463

464464
#### Open questions
465465

466-
While type packs cannot be written directly, a requirement where both sides are concrete types is desugared using the type matching algorithm, therefore it will be possible to write down a requirement that constraints a type parameter pack to a concrete type pack, unless some kind of restriction is imposed:
466+
While type packs cannot be written directly, a requirement where both sides are concrete types is desugared using the type matching algorithm, therefore it will be possible to write down a requirement that constrains a type parameter pack to a concrete type pack, unless some kind of restriction is imposed:
467467

468468
```swift
469469
func append<each S: Sequence>(_: repeat each S, _: repeat each T) where (each S).Element == (Int, String) {}

0 commit comments

Comments
 (0)