[swift-evolution] Pitch: @autoreleasepool attribute for loops

Greg Parker gparker at apple.com
Sat Jan 9 14:21:51 CST 2016

> On Jan 8, 2016, at 10:00 PM, Jacob Bandes-Storch via swift-evolution <swift-evolution at swift.org> wrote:
> I sympathize with the problem statement, but I wonder if we should instead be considering ways of allowing control-flow statements (break, continue, return) to work from inside @noescape closures.

@noescape is insufficient to allow that. You need more constraints on the closure's caller, perhaps even cooperation from the closure's caller depending on how the control flow is supposed to work.

Off the top of my head:
* The closure's caller can't call the closure more than once. Or if it does, it needs to participate in the control flow system somehow. (Example: what does `break` do in the middle of map().)
* Return values are complicated. You might need to limit the system to void returning closures only.
* Defining the closure in one place and handing it off in another is complicated. You might need to limit the system to closure literals only.

Greg Parker     gparker at apple.com <mailto:gparker at apple.com>     Runtime Wrangler

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160109/9ab0b2f5/attachment.html>

More information about the swift-evolution mailing list