[swift-evolution] Proposal: Closures capture weak by default

Paul Cantrell cantrell at pobox.com
Tue Dec 8 11:01:17 CST 2015

> For 'let' properties of classes, it'd be reasonable to propose having closures capture the *property* directly by default in this way instead of capturing ‘self'

That would be fantastic.

I’ve also wondered whether there’s a tidy way for a closure to be tied to the lifecycle of self, so that when self goes away, the closure goes away too. That’s often the desired behavior. On a casual thinking through, though, it seems like a can of worms — and the “guard let self = self else { return }” proposal on another thread gives most of the same benefit.


More information about the swift-evolution mailing list