# Pitch: Syntactic sugar for circumventing closure capture lists

**URL:** <https://forums.swift.org/t/pitch-syntactic-sugar-for-circumventing-closure-capture-lists/23425>\
**Category:** Pitches\
**Created:** [April 20, 2019, 11:05pm UTC](https://forums.swift.org/t/pitch-syntactic-sugar-for-circumventing-closure-capture-lists/23425 "2019-04-20T23:05:35Z")\
**Posts on this page:** 1\
**Showing post:** 61

<div class="post-metadata">

**Author:** ![Josh\_Osborne](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/josh_osborne/32/833_2.png) [@Josh\_Osborne](https://forums.swift.org/u/Josh_Osborne)\
**Post date:** [May 1, 2019, 12:41am UTC](https://forums.swift.org/t/pitch-syntactic-sugar-for-circumventing-closure-capture-lists/23425/61 "2019-05-01T00:41:42Z")

</div>

> [@GetSwifty](#):
>
> What situations are there where that would have a negative result? Assuming the performance is close enough to not be relevant.

Sometimes you _want_ to keep the object alive until the callback happens.

For example if you have an object that takes significant time to serialize & save you might want to dispatch\_async that to to some background queue and serialize and store it. I would expect that most dispatch\_async uses actually want to extend the lifetime of whatever they capture.

Objects participating in some sort of network RPC might want to live long enough for the existing set of outstanding calls to complete (or timeout) and handle the replies. I wouldn't say "most" of these want to extend the lifetimes of any captured objects, but a lot do...or at least frequently wouldn't cause problems.

Sadly we don't have a way to annotate function arguments as "will escape, but has a short lifetime", nor do we even really have a good definition of "short". Does a 0.1 second timer count as "short"? Does the same timer count as short if the target queue might be suspended? Is "when the RPC completes" soon?

That said if weak were the default you will get reminded as soon as you get an "need to unwrap" reminder that you ought to either unwrap the value, or change the capture list to capture self strongly.

---

_[View the full topic](https://forums.swift.org/t/pitch-syntactic-sugar-for-circumventing-closure-capture-lists/23425)._
