[swift-evolution] [Proposal] Allow upgrading weak self to strong self by assignment
Pierre Monod-Broca
pierre at monod-broca.fr
Tue Feb 23 00:53:03 CST 2016
I like the proposal also.
--
Pierre
> Le 22 févr. 2016 à 20:16, Evan Maloney via swift-evolution <swift-evolution at swift.org> a écrit :
>
> 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 <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 <mailto: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.
>>
>>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20160223/9e8c28e3/attachment.html>
More information about the swift-evolution
mailing list