# Labeled trailing closures

**URL:** <https://forums.swift.org/t/labeled-trailing-closures/90202>\
**Category:** Discussion\
**Tags:** syntax, closure, argument-labels\
**Created:** [October 22, 2026, 12:50pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202 "2026-10-22T12:50:00Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [October 22, 2026, 12:50pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/1 "2026-10-22T12:50:01Z")

</div>

Is there any appetite for allowing argument labels to be applied to the first trailing closure of a call expression? As things are now, we have to choose between indenting all closure arguments:

```swift
presentDeletionModal(
    for: selectedDocument,
    onConfirm: {
        // ...
    },
    onCancel: {
        // ...
    }
)

```

or forgoing a potentially illuminating argument label for the first trailing closure argument:

```swift
presentDeletionModal(
    for: selectedDocument
) {
    // ...
} onCancel: {
    // ...
}

```

I would often prefer:

```swift
presentDeletionModal(
    for: selectedDocument
) onConfirm: {
    // ...
} onCancel: {
    // ...
}

```

---

<div class="post-metadata">

**Author:** ![Jon\_Shier](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jon_shier/32/921_2.png) [@Jon\_Shier](https://forums.swift.org/u/Jon_Shier)\
**Post date:** [October 22, 2026, 3:16pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/2 "2026-10-22T15:16:33Z")

</div>

@xwu had a syntax for this back when trailing closures were first reviewed, and this was a huge point of contention during the review. Personally I'd still appreciate it.

---

<div class="post-metadata">

**Author:** ![aviva](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/aviva/32/44327_2.png) [@aviva](https://forums.swift.org/u/aviva)\
**Post date:** [October 22, 2026, 4:07pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/3 "2026-10-22T16:07:11Z")

</div>

This looks nice but I wonder if it introduces more ambiguity... _which_ trailing closure review was it discussed in @Jon_Shier?

---

<div class="post-metadata">

**Author:** ![scanon](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/scanon/32/2445_2.png) [@scanon](https://forums.swift.org/u/scanon)\
**Post date:** [October 22, 2026, 4:37pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/4 "2026-10-22T16:37:42Z")

</div>

I don't remember that specific comment, but it would have almost certainly been in the second review of SE-0279.

---

<div class="post-metadata">

**Author:** ![benrimmington](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/benrimmington/32/695_2.png) [@benrimmington](https://forums.swift.org/u/benrimmington)\
**Post date:** [October 22, 2026, 4:44pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/5 "2026-10-22T16:44:40Z")

</div>

[https://forums.swift.org/t/support-use-of-an-optional-label-for-the-first-trailing-closure/36371/13](https://forums.swift.org/t/support-use-of-an-optional-label-for-the-first-trailing-closure/36371/13)

---

<div class="post-metadata">

**Author:** ![benrimmington](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/benrimmington/32/695_2.png) [@benrimmington](https://forums.swift.org/u/benrimmington)\
**Post date:** [October 22, 2026, 4:54pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/6 "2026-10-22T16:54:11Z")

</div>

[https://forums.swift.org/t/principles-for-trailing-closure-evolution-proposals/37265](https://forums.swift.org/t/principles-for-trailing-closure-evolution-proposals/37265)

---

<div class="post-metadata">

**Author:** ![xwu](https://avatars.discourse-cdn.com/v4/letter/x/b487fb/32.png) [@xwu](https://forums.swift.org/u/xwu)\
**Post date:** [October 22, 2026, 5:18pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/7 "2026-10-22T17:18:01Z")

</div>

🙃🙃

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [October 22, 2026, 8:06pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/8 "2026-10-22T20:06:30Z")

</div>

> [@jeremyabannister](#):
>
> ```swift
> I would often prefer:
> 
> presentDeletionModel(
> for: selectedDocument
> ) onConfirm: {
> // ...
> } onCancel: {
> // ...
> }
> 
> ```

How would that look without the "for: selectedDocument" parameter, like so?

```swift
presentDeletionModel() onConfirm: {} onCancel: {}

```

Note that with the normal unlabelled trailing closure the () are optional, but here it would probably not work:

```swift
presentDeletionModel onConfirm: {} onCancel: {}

```

---

<div class="post-metadata">

**Author:** ![allevato](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/allevato/32/385_2.png) [@allevato](https://forums.swift.org/u/allevato)\
**Post date:** [October 22, 2026, 9:25pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/9 "2026-10-22T21:25:19Z")

</div>

Why wouldn't it?

There are very few places in expression grammars where two identifiers are juxtaposed, and many of them revolve around disambiguating contextual keywords (like `copy x` treats `copy` as a keyword but `copy(x)` treats it as an identifier). I suspect a parser rule that treats `<expr> <identifier>:` as a no-arg call followed by a trailing closure label would be unambiguous.

---

<div class="post-metadata">

**Author:** ![clayellis](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/clayellis/32/43646_2.png) [@clayellis](https://forums.swift.org/u/clayellis)\
**Post date:** [October 22, 2026, 9:36pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/10 "2026-10-22T21:36:33Z")

</div>

Hahaha yep... looks like we've arrived at the can we kicked down the road 😅

---

<div class="post-metadata">

**Author:** ![tera](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/tera/32/38201_2.png) [@tera](https://forums.swift.org/u/tera)\
**Post date:** [October 22, 2026, 10:25pm UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/11 "2026-10-22T22:25:49Z")

</div>

> [@allevato](#):
>
> Why wouldn't it?

You are right, it feels unusual but could actually work.

---

<div class="post-metadata">

**Author:** ![Nobody1707](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/nobody1707/32/2169_2.png) [@Nobody1707](https://forums.swift.org/u/Nobody1707)\
**Post date:** [October 23, 2026, 2:22am UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/12 "2026-10-23T02:22:30Z")

</div>

I don't remember if I mentioned it at the time, but I'm definitely for this. Every now and then I try this and and am always disappointed that it doesn't work.

---

<div class="post-metadata">

**Author:** ![maartene](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/maartene/32/42076_2.png) [@maartene](https://forums.swift.org/u/maartene)\
**Post date:** [October 23, 2026, 8:15am UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/13 "2026-10-23T08:15:54Z")

</div>

at least offering the _option_ to add a label to the first closure would be something I appreciate very much.

---

<div class="post-metadata">

**Author:** ![jeremyabannister](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/jeremyabannister/32/10143_2.png) [@jeremyabannister](https://forums.swift.org/u/jeremyabannister)\
**Post date:** [October 23, 2026, 9:01am UTC](https://forums.swift.org/t/labeled-trailing-closures/90202/14 "2026-10-23T09:01:29Z")

</div>

That’s all that’s on the table - changes that break preexisting code are very problematic at this point, and only accepted if the problem they solve is even worse
