[swift-evolution] Guaranteed closure execution
rodney.brown6 at icloud.com
Sat Jan 30 18:54:19 CST 2016
Yes, I agree. Very good points.
> On 31 Jan 2016, at 8:55 AM, Chris Lattner via swift-evolution <swift-evolution at swift.org> wrote:
>> On Jan 30, 2016, at 12:19 PM, Jacob Bandes-Storch via swift-evolution <swift-evolution at swift.org> wrote:
>> The "noescape + exactly once" guarantee is useful to the compiler because it allows the closure to *initialize* variables that it captures. The way to think about this is that the closure body is effectively inlined.
>> "noescape, but not exactly once" is still useful because you can omit references to self, and know that variable modifications in the closure will be visible after the function call. But you can't perform initialization (because the closure might be called more than once), nor can you be sure variables are initialized after the function call (because the closure might not be called at all).
>> "exactly once, but escaping" is an important API contract that should be documented, but if the closure can escape the call, then you still can't perform initialization in the closure, because the order it happens in w.r.t. the function call isn't guaranteed. I might be missing something, but I don't see any reason for this feature to exist, because...well, it isn't really a feature if it can't do anything.
> +1, exactly right.
> swift-evolution mailing list
> swift-evolution at swift.org
More information about the swift-evolution