[swift-evolution] [Draft] @selfsafe: a new way to avoid reference cycles

Brent Royal-Gordon brent at architechies.com
Sun Feb 19 23:05:20 CST 2017


> On Feb 19, 2017, at 7:06 PM, Matthew Johnson <matthew at anandabits.com> wrote:
> 
> Often you hand it to something owned by self, but it's also the case that you often hand it to something not owned by self, but that should not extend the lifetime of self.

I don't agree that it shouldn't extend the lifetime of `self`. By default, Swift assumes that if you capture an object in a closure, you want that object to stay alive as long as the closure does.

I see absolutely no reason that this assumption should be different for `self` than it is for any other variable, and I see no reason to believe the caller would have a particularly good idea about this.

-- 
Brent Royal-Gordon
Architechies



More information about the swift-evolution mailing list