[swift-evolution] Proposal: Allow `[strong self]` capture in closures and remove the `self` requirement therein
gparker at apple.com
Thu Dec 17 17:43:15 CST 2015
> On Dec 17, 2015, at 1:46 AM, Andrey Tarantsov via swift-evolution <swift-evolution at swift.org> wrote:
> +1, this has been a noticeable source of annoyance. Marc Knaup has said it best:
>> Developers will likely only ever write the rather uncommon [strong self] capture when they know what they are doing.
>> Misuse can happen with any feature, but it is unlikely in this case.
> I *am* concerned about an inconsistency here, though; is [strong self] just a magical workaround for one specific case, or could this be a part of a larger rule?
`self` is already special in closures. This is merely a change to its special behavior.
I can think of two possible amendments that would make self capture more consistent with other variables.
1. Allow or require plain `[self]` instead of `[strong self]`.
2. Allow or require other captures to use `strong` as the capture specifier: `[strong y = x]`
Greg Parker gparker at apple.com Runtime Wrangler
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the swift-evolution