# SE-0279: Multiple Trailing Closures \[Amended\]

**URL:** <https://forums.swift.org/t/se-0279-multiple-trailing-closures-amended/35435>\
**Category:** Proposal Reviews\
**Created:** [April 16, 2020, 10:35pm UTC](https://forums.swift.org/t/se-0279-multiple-trailing-closures-amended/35435 "2020-04-16T22:35:06Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![jrose](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jrose/32/408_2.png) [@jrose](https://forums.swift.org/u/jrose)\
**Post date:** [April 16, 2020, 11:06pm UTC](https://forums.swift.org/t/se-0279-multiple-trailing-closures-amended/35435/2 "2020-04-16T23:06:29Z")

</div>

I understand how existing syntax encourages removing the argument label from the _first_ trailing closure rather than the _final_ trailing closure, but I'm worried that this puts us at odds with APIs designed for pre-Swift-5 code, which would put the "heaviest" closure last and "light" ones in the middle in order to make existing trailing closure syntax feel natural. I admit I don't have any real-world examples of such API, but there's a reason for that beyond trailing closure syntax: the "heaviest" closure is the one that likely goes on the longest, and you wouldn't want to have to scroll past it to see that there are more arguments.

```swift
Section {
  List(…) {
    HStack(…) {
      // may go on for many lines
    }
  }
} header: {
  ...
} footer: {
  ...
}

```

(sorry for the straw example; I don't do SwiftUI very much.)

On a more nebulous note, it also feels weird to me that all of these are the same call:

> ****
>
> ```swift
> foo(bar: { provideBar() }, baz: { provideBaz() }, garply: { provideGarply() })
> 
> foo(bar: { provideBar() }, baz: { provideBaz() }) {
> provideGarply()
> }
> 
> foo(bar: { provideBar() }) {
> provideBaz()
> } garply: {
> provideGarply()
> }
> 
> foo() {
> provideBar()
> } baz: {
> provideBaz()
> } garply: {
> provideGarply()
> }
> 
> ```

Which argument label is omitted is completely up to the call site. I've been a proponent of trailing closures for a long time, and pushed back against people who complain about the last argument label being omitted, but this gets to a point that makes me uneasy, though I can't quite pin down why. (Usually I'm the one who says "people can write bad code in any language".)

* * *

I'm sure this was already discussed, but I'd be much more comfortable with "all trailing closures take an argument label; if there is exactly one trailing closure, the argument label may be omitted".

```swift
foo() bar: {
  provideBar()
} baz: {
  provideBaz()
} garply: {
  provideGarply()
}

```

Slightly odd-looking? Perhaps. But it keeps the _name omission_ part from being coupled to the _ordering_ part, and I think that's potentially useful when the rule for name omission isn't just "the final argument label".

---

_[View the full topic](https://forums.swift.org/t/se-0279-multiple-trailing-closures-amended/35435)._
