[swift-evolution] Guaranteed closure execution

Brent Royal-Gordon brent at architechies.com
Fri Jan 29 04:58:42 CST 2016


> You are right Jacob, a modifier `@noescape(once)` would be better, as it would help compiler distinguish between assignment and initialization of captured variables.
> 
> The utility of such a new feature is maybe tiny, but clear: it extends the opportunities to declare variables before initializing them. The Swift 1 to 2 transition has already extended those opportunities, so we’re just following an existing trend, here.

I actually think that `once` is orthogonal to `noescape`. There are a *lot* of closures that are not noescape, but are called exactly once, such as dispatch_async and most completion handlers.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list