<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=""><br class=""><div><blockquote type="cite" class=""><div class="">On 16 Aug 2016, at 15:49, Xiaodi Wu 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="">I can see the use case, but it'd be annoying (or, impossible) to work around if I intend to call `end` by passing it to a helper function in another (let's say, precompiled) module. There's no way for the compiler to inspect that `end` is always called by that other module, and if calling `end` twice causes bad things to happen, I'm totally out of luck. You'd need a companion annotation to pass along the requirement to the callee, or some sort of force-unrequire, but the latter can't have teeth (i.e. can't enforce at runtime) if the closure is escaping.<br class=""><div class="gmail_quote"><div dir="ltr" class="">On Tue, Aug 16, 2016 at 08:39 James Campbell via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> 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_default" style="font-family: arial, helvetica, sans-serif; font-size: small;">It would be handy if a callback could be marked as required with an optional descriptive message i.e</div><div class="gmail_default" style="font-family: arial, helvetica, sans-serif; font-size: small;"><br class=""></div><div class="gmail_default" style="font-family: arial, helvetica, sans-serif; font-size: small;">class BackgroundTask {</div><div class="gmail_default" style="font-family: arial, helvetica, sans-serif; font-size: small;"> func run(end: @required("You must call end otherwise iOS will penalise your app for being a bad citizen") () -> Void) </div><div class="gmail_default" style="font-family: arial, helvetica, sans-serif; font-size: small;">}</div><div class="gmail_default" style="font-family: arial, helvetica, sans-serif; font-size: small;"><br class=""></div><div class="gmail_default" style="font-family: arial, helvetica, sans-serif; font-size: small;">That was the developer can comunicate the bad things that can happen if this callback isn't called such as iOS peanlizing them for not ending a background task or perhaps memory leaks caused by clean up code unable to be triggered.</div></div></blockquote></div></div></blockquote><br class=""></div><div>Could this not just behave in the same way as @noescape, in which case you can pass the closure on to other functions so long as they also have the @noescape attribute? In this case passing it as a parameter to another method with the @required attribute would be equivalent to calling it directly (since you know the other method must eventually call it).</div></body></html>