<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 1, 2016, at 2:46 PM, Chris Lattner <<a href="mailto:clattner@apple.com" class="">clattner@apple.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><span style="font-family: Helvetica; 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; float: none; display: inline !important;" class="">On Feb 1, 2016, at 6:31 AM, Matthew Johnson via swift-evolution <</span><a href="mailto:swift-evolution@swift.org" class="" style="font-family: Helvetica; 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;">swift-evolution@swift.org</a><span style="font-family: Helvetica; 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; float: none; display: inline !important;" class="">> wrote:</span><div style="font-family: Helvetica; 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=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class=""></div><blockquote type="cite" class=""><div class=""><font color="#5856d6" class="">func foo() {</font></div><div class=""><font color="#5856d6" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let bar: Int</font></div><div class=""><font color="#5856d6" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>withNoEscape { bar = 1 }</font></div><div class=""><font color="#5856d6" class="">}</font></div><div class=""><font color="#5856d6" class=""><br class=""></font></div><div class=""><font color="#5856d6" class="">func withNoEscape(@autoclosure(once) closure: () -> ()) { /* snip */ }</font></div></blockquote></div><div class=""><br class=""></div>Looking back, I do think that there should be a way to exit from `withNoEscape` without calling the closure, so yes, throwing should imply that the closure wasn't executed. If it's possible that `foo` swallowed an error from a throwing `withNoEscape`, the compiler should assume that the variables within haven't been initialized:</div></div></blockquote><br class=""></div><div class="">I’m glad to see an @autoclosure func in this thread. We will want to be able to use this feature with @autoclosure in addition to @noescape.</div><div class=""><br class=""></div></div></div></blockquote><blockquote type="cite" class=""><div class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class="">As far as exiting without calling the closure, I suggest `@noescape(once?)`. The `?` indicates the closure may or may not be called, but<span class="Apple-converted-space"> </span><b class="">will not</b> be called more than once.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I don’t see how this is useful. You wouldn’t be able to initialize a value with this semantic, so it isn’t any more powerful than @noescape on the caller side.</div></div></div></blockquote><div><br class=""></div><div>Right, you would not be able to use it for initialization.</div><div><br class=""></div>It gives a guarantee that the closure will not be executed twice. This semantic guarantee could be useful, especially if the closure has side-effects. It adds the clarity of a guarantee to APIs where the zero-or-one-times semantic is implicit with @noescape alone.</div><div><br class=""></div><div>-Matthew </div><div> <br class=""><blockquote type="cite" class=""><div class=""><div style="font-family: Helvetica; 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=""><div class=""><br class=""></div><div class="">-Chris</div></div></div></blockquote></div><br class=""></body></html>