[swift-evolution] [Proposal] Allow upgrading weak self to strong self by assignment
Evan Maloney
emaloney at gilt.com
Mon Feb 22 13:16:19 CST 2016
Thanks for the feedback, Andrew. I will incorporate it in the next draft, to be sent shortly.
Incidentally, I found Chris Lattner's response about assigning `self`, specifically his statement that "this is a compiler bug":
https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20160118/007425.html
> On Feb 20, 2016, at 3:55 AM, Andrew Bennett <cacoyi at gmail.com> wrote:
>
> Yes, I only learnt about it from Chris Lattner's comment. Great idea to do it right :)
>
> If I remember correctly I think he said not to rely on it because it wasn't intentional. I'm not sure if he said it was undesirable. I thought it may be worth mentioning in case you didn't know, and because it may help the proposal if it had:
> you can already do `self` = self, but it's not officially supported
> this formalises that ability, and removes the need for backticks
> Also, you may want to mention that this *only* works between `self` and `[weak self]`, ie. you cannot do:
>
> guard self = Optional.Some(123) else { ... }
>
>
> On Sat, Feb 20, 2016 at 1:18 PM, Evan Maloney <emaloney at gilt.com <mailto:emaloney at gilt.com>> wrote:
> > On Feb 19, 2016, at 8:40 PM, Andrew Bennett via swift-evolution <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
> >
> > A quick note, I'm not sure if it's a hack but you can probably still do this:
> >
> > guard let `self` = self else { return }
>
> IIRC, the fact that this works is accidental and Chris Lattner mentioned that it should be considered a bug.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160222/1608e22d/attachment.html>
More information about the swift-evolution
mailing list