# \[Review\] SE-0408: Pack Iteration

**URL:** <https://forums.swift.org/t/review-se-0408-pack-iteration/67152>\
**Category:** Proposal Reviews\
**Created:** [September 6, 2023, 4:59pm UTC](https://forums.swift.org/t/review-se-0408-pack-iteration/67152 "2023-09-06T16:59:28Z")\
**Posts on this page:** 1\
**Showing post:** 18

<div class="post-metadata">

**Author:** ![ellie20](https://avatars.discourse-cdn.com/v4/letter/e/6f9a4e/32.png) [@ellie20](https://forums.swift.org/u/ellie20)\
**Post date:** [September 7, 2023, 7:17am UTC](https://forums.swift.org/t/review-se-0408-pack-iteration/67152/18 "2023-09-07T07:17:38Z")

</div>

In my opinion, the `for` loop-like syntax is unlike other places where variadic generics can be used, where the repeated value is marked by the `each` keyword. With the `for` syntax, the repeated value has to be bound to an iteration variable before use. This has the benefit of making it more obvious what value is being repeated, and feeling intuitively similar to a `for` loop. But it also has the disadvantage that making one variadic value syntactically "privileged" can become arbitrary. For example, there's no reason why this:

```swift
for (left, right) in repeat (each lhs, each rhs) {
    guard left == right else { return false }
}

```

couldn't be written like this:

```swift
repeat {
    let (left, right) = (each lhs, each rhs)
    guard left == right else { return false }
}

```

Going back to what ensan-hcl said earlier in this thread, the [`allUnwrapOrNil`](https://forums.swift.org/t/pitch-enable-pack-iteration/66168/3) could be written like this:

```swift
func allUnwrapOrNil<each Element>(over element: repeat (each Element)?) -> (repeat each Element)? {
    let result: (repeat each Element)
    repeat {
        guard let element = each element else {
            return nil
        }
        each result = element
    }
    return result
}

```

In this case, the repeated value (`each result`) is an lvalue. The `for` loop-like syntax where repeated values are bound at the top would only allow rvalues.

---

_[View the full topic](https://forums.swift.org/t/review-se-0408-pack-iteration/67152)._
