<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 3, 2016, at 4:45 PM, Dany St-Amant via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 3 févr. 2016 à 19:22, Chris Lattner via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 3, 2016, at 3:00 PM, Félix Cloutier <<a href="mailto:felixcca@yahoo.ca" class="">felixcca@yahoo.ca</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Thanks. I have updated the proposal to reflect this.<div class=""><br class=""></div><div class="">One thing that remains unspecified is the behavior when the closure throws. Feedback and opinions would be very welcome here.</div><div class=""><br class=""></div><div class="">Some alternatives that I can think of:</div><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class="">disallow throwing from @noescape(once) closures;</li></ul></div></div></div></blockquote><div class=""><br class=""></div><div class="">I’d strongly prefer this. Once/if the base proposal is accepted and implemented, we can always expand from there if strong motivation exists for doing so.</div><div class=""><br class=""></div><div class="">-Chris</div></div></div></div></blockquote><div class=""><br class=""></div><div class="">Previously I had thought of the try? and try! but even with plain try the compiler might not know if a variable is initialized or not if the @noescape(once) <b class="">must not</b> run on throws</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">let</span> foo: <span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">do</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">try</span> withLock(someLock, timeout: <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">0.5</span>) {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">foo</span> = sharedThing.foo</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> }</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="" class=""> </span>// immutable foo can be read not written to</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="" class="">} </span>catch<span style="" class=""> {</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);" class=""><span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #3d1d81" class="">print</span><span style="" class="">(</span>"couldn't acquire lock fast enough"<span style="" class="">)</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class="">// is immutable foo initialized or not, must prevent both reads and writes</div><div class=""><br class=""></div></div><div class="">So will the compiler be able to properly handle this ambiguity?</div></div></div></div></blockquote><br class=""></div><div>I believe so, but I can’t say with 100% certainty without diving into some more details.</div><div><br class=""></div><div>-Chris</div><br class=""></body></html>