<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="">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><li class="">allow throwing and allow the error to be re-thrown (and force `once` closures to be executed on throwing paths);</li><li class="">return the closure error (possibly incompatible with some function return types).</li></ul><div class="">
<br class="Apple-interchange-newline"><span style="color: rgb(0, 0, 0); font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none;" class="">Félix</span>
</div>
<br class=""><div><blockquote type="cite" class=""><div class="">Le 3 févr. 2016 à 17:18:51, Chris Lattner &lt;<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><blockquote type="cite" class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><br class="Apple-interchange-newline">On Feb 3, 2016, at 1:21 PM, Félix Cloutier &lt;<a href="mailto:felixcca@yahoo.ca" class="">felixcca@yahoo.ca</a>&gt; wrote:</div><br class="Apple-interchange-newline"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">I updated the proposal to address some concerns. It can be found at:&nbsp;<a href="https://github.com/zneak/swift-evolution/blob/master/proposals/00xx-noescape-once.md" class="">https://github.com/zneak/swift-evolution/blob/master/proposals/00xx-noescape-once.md</a><div class=""><br class=""></div><div class="">Things that changed:</div><div class=""><br class=""></div><div class=""><ul class="MailOutline"><li class="">It now says that the closure must be called on code paths where the function throws;</li><li class="">you can have multiple @noescape(once) parameters but they can't make assumptions from one another.</li></ul><div class=""><br class=""></div><div class="">I'm not 100% convinced that forcing a call on code paths that throw is always desirable. I've changed it because Chris's support probably means that the feature has better chances of making it, but I'm not convinced yet.<span class="Apple-converted-space">&nbsp;</span></div></div></div></div></blockquote><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">To be clear, (once) needs to specify either that the closure is guaranteed to be executed on the error path, or that it is guaranteed not to be. &nbsp;I can see the argument that “guaranteed not” is the best default. &nbsp;If you think that is the best way to go, feel free to make that be the proposal. &nbsp;Either way, please mention in “alternatives” that it needs to be one or the other, but could be switched (from whatever you propose) if there is a compelling reason.</div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><br class=""></div><div style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">-Chris</div><br class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><blockquote type="cite" class="" style="font-family: LucidaGrande; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">If throwing allows me to return without calling the closure, I can write this:</div><div class=""><br class=""></div><div class=""><div class="">do {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let foo: Int</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>try withLock(someLock, timeout: 0.5) {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">                </span>foo = sharedThing.foo</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</div><div class="">} catch {</div><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>print("couldn't acquire lock fast enough")</div><div class="">}</div></div><div class=""><br class=""></div><div class="">which would be kind of messy if instead, the closure needed a parameter to tell whether the lock was acquired or not when it runs.</div><div class=""><div class=""><br class="Apple-interchange-newline"><span class="" style="font-family: 'Lucida Grande'; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;">Félix</span></div></div></div></div></div></blockquote></div></blockquote></div><br class=""></div></body></html>