<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class="">I think it's important to defer to the programmer on how the weak self condition is handled, enabling any clean-up action to be taken as well as deciding whether to terminate the app, recover, etc.</div><div class=""><br class=""></div><div class="">-- E</div><div class=""><br class=""></div><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 12, 2016, at 3:20 PM, Jason Gregori <<a href="mailto:jasongregori@gmail.com" class="">jasongregori@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Ah, I see. I think that totally makes sense but I would prefer to have just one bit to write and not have to do both the [weak self] and the guard statement. <div class=""><br class=""></div><div class="">This is why I keep coming back to [guard weak self]. I want to to make self weak and I want to guard against it being nil.</div></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Feb 12, 2016 at 1:31 PM, Erica Sadun <span dir="ltr" class=""><<a href="mailto:erica@ericasadun.com" target="_blank" class="">erica@ericasadun.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">It would follow </div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">[weak self]</font></div><div class=""><br class=""></div><div class="">not replace it, e.g.</div><div class=""><br class=""></div><div class=""><div class=""><font face="Menlo" class="">[weak self]</font></div></div><span class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div style="word-wrap:break-word" class=""><div class=""><font face="Menlo" class="">guard reconstitute self else { return }</font></div></div></div></div></div></div><div class=""><br class=""></div></span><div class="">I thought it might be handy to control how the <font face="Menlo" class="">guard</font> exits scope, enabling <font face="Menlo" class="">self == nil</font> (as well as any other reconstitutions of a <font face="Menlo" class="">weak</font> variable) failure cases to do reporting, <font face="Menlo" class="">fatalError</font>-ing, etc.</div><span class="HOEnZb"><font color="#888888" class=""><div class=""><br class=""></div><div class="">-- E</div></font></span><div class=""><div class="h5"><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 12, 2016, at 12:08 PM, Jason Gregori <<a href="mailto:jasongregori@gmail.com" target="_blank" class="">jasongregori@gmail.com</a>> wrote:</div><br class=""><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Feb 12, 2016 at 10:34 AM, Erica Sadun <span dir="ltr" class=""><<a href="mailto:erica@ericasadun.com" target="_blank" class="">erica@ericasadun.com</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">How about </div><div class=""><br class=""></div><div class=""><font face="Menlo" class="">guard reconstitute self else { return }</font></div></div></blockquote><div class=""><br class=""></div><div class="">I like the idea behind this but I feel like a line inside the block can't really dictate whether self is captured weakly or not. Unless your saying put this in the bracket part?</div><div class=""><br class=""></div><div class="">[guard reconstitute self] ? That works for me.</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">PS: I got here from your blog post, thanks!</div><div class=""> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><font face="Palatino-Roman" class="">-- E</font></div><br class=""><div class=""><blockquote type="cite" class=""><div class=""><div class=""><div class="">On Feb 12, 2016, at 11:28 AM, Jason Gregori via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class=""></div></div><div class=""><div class=""><div class=""><div dir="ltr" class=""><span style="font-size:13px" class="">I like Kenny and Kurt's points about handling the majority case and keeping the syntax simpler.</span><br style="font-size:13px" class=""><div style="font-size:13px" class=""><br class=""></div><div style="font-size:13px" class="">I feel like most of the time I want to break a retain cycle is for a completion block which returns void. Can we just handle that case and get rid of the else?<br class=""></div><div style="font-size:13px" class=""><br class=""></div><div style="font-size:13px" class="">Also, I don't think [guard self] is self explanatory enough. I think weak should be in there so it's much more obvious you are doing the weak/strong dance with self, otherwise it looks like you are guarding against a regular optional being nil.</div><div style="font-size:13px" class=""><br class=""></div><div style="font-size:13px" class="">So:</div><div style="font-size:13px" class=""><br class=""></div><div style="font-size:13px" class="">[guard weak self, other]</div></div></div></div>
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></blockquote></div><br class=""></div></div>
</div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div>
</div></blockquote></div><br class=""></body></html>