<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Even if that would be possible, you’d need to ensure that the RC of the object is not reduced to zero between your check and the end of the closure (that was the criticism with the first version of Evan’s proposal). I also read your comment sin the other thread and they seem quite focused on the unowned self case. I am not sure that its that frequent. When you sue closures for callbacks and/or signals, using weak self makes more sense to me. Another problem I have with the alternative proposal (guard self in the capture list) is that it does not offer an obvious way to remove the closure once the object leaves the scope. Imagine that I am using closures for some sort of observing or notification mechanism. There can potentially be many short-lived objects who receive notifications from a single source. With Evan’s proposal, I can do something like this:<div class=""><br class=""></div><div class="">guard self = self &nbsp;else &nbsp;{ remove the current closure from the notification list; return }</div><div class=""><br class=""></div><div class="">I don’t see an obvious way to accomplish this in the alternative proposal.&nbsp;</div><div class=""><br class=""></div><div class="">Best,&nbsp;</div><div class=""><br class=""></div><div class="">&nbsp;Taras&nbsp;<br class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><div class=""><div><blockquote type="cite" class=""><div class="">On 20 Feb 2016, at 08:52, Kurt Werle &lt;<a href="mailto:kurt@circlew.org" class="">kurt@circlew.org</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class="">Arg!&nbsp; My mistake - I did not realize you can't test an unowned to be nil like you can an implicitly unwrapped variable.</div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Fri, Feb 19, 2016 at 11:03 PM, Shawn Erickson <span dir="ltr" class="">&lt;<a href="mailto:shawnce@gmail.com" target="_blank" class="">shawnce@gmail.com</a>&gt;</span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">True, however only if unowned works in terms of the desired object life time / "ownership" for self. It isn't always sufficient so weak is needed to avoid the retain cycle while safely supporting self becoming nil (e.g. allowing the object referenced by self to go away while the block may still be outstanding). The proposal outlines at least one example of that need and is written assuming you need to use weak.<div class="HOEnZb"><div class="h5"><br class=""><div class="gmail_quote"><div dir="ltr" class="">On Fri, Feb 19, 2016 at 10:15 PM Kurt Werle &lt;<a href="mailto:kurt@circlew.org" target="_blank" class="">kurt@circlew.org</a>&gt; wrote:<br class=""></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote">On Fri, Feb 19, 2016 at 9:04 PM, Evan Maloney <span dir="ltr" class="">&lt;<a href="mailto:emaloney@gilt.com" target="_blank" class="">emaloney@gilt.com</a>&gt;</span> wrote:</div><div class="gmail_quote"><div class=""><br class=""></div><div class="">...&nbsp;</div></div></div></div><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class=""><p style="margin-top:0px;margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class="">With this feature, the code above could be rewritten as:</p><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px;background-color:rgb(255,255,255)" class=""><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;background-color:rgb(247,247,247)" class="">networkRequest<span style="color:rgb(167,29,93)" class="">.</span>fetchData() { [<span style="color:rgb(167,29,93)" class="">weak</span> <span style="color:rgb(167,29,93)" class="">self</span>] result <span style="color:rgb(167,29,93)" class="">in</span>
    <span style="color:rgb(167,29,93)" class="">guard</span> <span style="color:rgb(167,29,93)" class="">let</span> <span style="color:rgb(167,29,93)" class="">self</span> <span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(167,29,93)" class="">self</span> <span style="color:rgb(167,29,93)" class="">else</span> { <span style="color:rgb(167,29,93)" class="">return</span> }</pre></div></div></div></blockquote></div></div></div><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class="">If you're going to have boilerplate like that, then the following seems like it accomplishes the same thing [in this specific case] without changing anything:</div><div class=""><br class=""></div><div class=""><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div style="margin-bottom:16px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol';font-size:16px" class=""><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:14px;margin-top:0px;margin-bottom:0px;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;background-color:rgb(247,247,247)" class="">networkRequest<span style="color:rgb(167,29,93)" class="">.</span>fetchData() { [<span style="color:rgb(167,29,93)" class="">unowned</span> <span style="color:rgb(167,29,93)" class="">self</span>] result <span style="color:rgb(167,29,93)" class="">in</span>
    <span style="color:rgb(167,29,93)" class="">guard</span> <span style="color:rgb(167,29,93)" class="">self</span> !<span style="color:rgb(167,29,93)" class="">=</span> <span style="color:rgb(167,29,93)" class="">nil</span> <span style="color:rgb(167,29,93)" class="">else</span> { <span style="color:rgb(167,29,93)" class="">return</span> }</pre></div></div></blockquote></div><div class="">&nbsp;</div><div class="">Kurt</div></div></div></div><div dir="ltr" class=""><div class="gmail_extra">-- <br class=""><div class=""><a href="mailto:kurt@circlew.org" class="">kurt@CircleW.org</a><br class=""><a href="http://www.circlew.org/kurt/" target="_blank" class="">http://www.CircleW.org/kurt/</a><br class=""></div>
</div></div></blockquote></div>
</div></div></blockquote></div><br class=""><br clear="all" class=""><div class=""><br class=""></div>-- <br class=""><div class="gmail_signature"><a href="mailto:kurt@circlew.org" class="">kurt@CircleW.org</a><br class=""><a href="http://www.circlew.org/kurt/" target="_blank" class="">http://www.CircleW.org/kurt/</a><br class=""></div>
</div>
</div></blockquote></div><br class=""></div></div></div></div></body></html>