Skip to content

Commit f1f35bf

Browse files
authored
Merge pull request swiftlang#72007 from simanerush/se-0408-changelog
[NFC] Add a release note for SE-0408.
2 parents 7cbe2cf + 404608b commit f1f35bf

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,42 @@
44
> This is in reverse chronological order, so newer entries are added to the top.
55
66
## Swift 6.0
7+
* [SE-0408][]:
8+
A `for`-`in` loop statement can now accept a pack expansion expression,
9+
enabling iteration over the elements of its respective value pack. This form
10+
supports pattern matching, control transfer statements, and other features
11+
available to a `Sequence`-driven `for`-`in` loop, except for the `where`
12+
clause. Below is an example implementation of the equality operator for
13+
tuples of arbitrary length using pack iteration:
14+
15+
```swift
16+
func == <each Element: Equatable>(lhs: (repeat each Element),
17+
rhs: (repeat each Element)) -> Bool {
18+
19+
for (left, right) in repeat (each lhs, each rhs) {
20+
guard left == right else { return false }
21+
}
22+
return true
23+
}
24+
```
25+
26+
The elements of the value pack corresponding to the pack expansion expression
27+
are evaluated on demand, meaning the i<sup>th</sup> element is evaluated on
28+
the i<sup>th</sup> iteration:
29+
30+
```swift
31+
func doSomething(_: some Any) {}
32+
33+
func evaluateFirst<each T>(_ t: repeat each T) {
34+
for _ in repeat doSomething(each t) {
35+
break
36+
}
37+
}
38+
39+
evaluateFirst(1, 2, 3)
40+
// 'doSomething' will be called only on the first element of the pack.
41+
```
42+
743
* [SE-0352][]:
844
The Swift 6 language mode will open existential values with
945
"self-conforming" types (such as `any Error` or `@objc` protocols)
@@ -10147,6 +10183,7 @@ using the `.dynamicType` member to retrieve the type of an expression should mig
1014710183
[SE-0394]: https://github.com/apple/swift-evolution/blob/main/proposals/0394-swiftpm-expression-macros.md
1014810184
[SE-0397]: https://github.com/apple/swift-evolution/blob/main/proposals/0397-freestanding-declaration-macros.md
1014910185
[SE-0407]: https://github.com/apple/swift-evolution/blob/main/proposals/0407-member-macro-conformances.md
10186+
[SE-0408]: https://github.com/apple/swift-evolution/blob/main/proposals/0408-pack-iteration.md
1015010187
[SE-0411]: https://github.com/apple/swift-evolution/blob/main/proposals/0411-isolated-default-values.md
1015110188
[SE-0417]: https://github.com/apple/swift-evolution/blob/main/proposals/0417-task-executor-preference.md
1015210189
[SE-0412]: https://github.com/apple/swift-evolution/blob/main/proposals/0412-strict-concurrency-for-global-variables.md

0 commit comments

Comments
 (0)