[swift-evolution] [Draft] @selfsafe: a new way to avoid reference cycles
David Hart
david at hartbit.com
Mon Feb 20 00:20:37 CST 2017
On 20 Feb 2017, at 06:05, Brent Royal-Gordon via swift-evolution <swift-evolution at swift.org> wrote:
>> 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.
Totally agree. The proposal would complicate reasoning about reference cycles and lifetime of objects by creating special cases which depend on what variable is concerned (self or other) and what the API does.
> --
> Brent Royal-Gordon
> Architechies
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
More information about the swift-evolution
mailing list