[swift-evolution] [Proposal] Allow upgrading weak self to strong self by assignment

Evan Maloney emaloney at gilt.com
Fri Feb 19 13:40:27 CST 2016


> On Feb 19, 2016, at 2:30 PM, plx via swift-evolution <swift-evolution at swift.org> wrote:
>> networkRequest.fetchData() { [weak self] result in
>>     guard self != nil else { return }
>> 
>>     let self = self!
> …isn’t there a race condition in this example (admittedly an *unlikely* one in most settings, but still…)?

Yes, that's a good point.

Now that I think about it, allowing a standalone `let self =` could never be implemented in a way *guaranteed* to avoid a race condition, so perhaps I should remove it from the proposal altogether.

When I incorporate the next round of feedback, I'll rework the proposal to indicate that it can only be used with `if let` or `guard let`.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160219/1cc3a858/attachment.html>


More information about the swift-evolution mailing list