<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=""><div class="">New start task: <a href="https://bugs.swift.org/browse/SR-4405" class="">https://bugs.swift.org/browse/SR-4405</a> Add @escaping to RecoverableError.attemptRecovery</div><div class=""><br class=""></div><br class=""><div style=""><blockquote type="cite" class=""><div class="">On Mar 28, 2017, at 3:31 PM, Douglas Gregor <<a href="mailto:dgregor@apple.com" class="">dgregor@apple.com</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="">On Mar 28, 2017, at 11:21 AM, Michael Ilseman <<a href="mailto:milseman@apple.com" class="">milseman@apple.com</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=""><div class="">CC Doug Gregor, who git blame tells me wrote this part.</div><div class=""><br class=""></div><div class="">Doug, this slightly predates noescape-by-default. Is this a bug or as intended?</div></div></div></blockquote><div class=""><br class=""></div><div class="">It’s a bug; the point here is that we can do recovery asynchronously, so it should be @escaping. We missed the annotation when noescape-by-default landed.</div><div class=""><br class=""></div><span class="Apple-tab-span" style="white-space:pre">        </span>- Doug</div><div class=""><br class=""><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><br class=""></div><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Mar 28, 2017, at 8:49 AM, Elia Cereda via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@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="">Hi Dennis,<div class=""><br class=""></div><div class="">Thanks for your answer. I can see that my message needs some more context: <span style="font-family: Menlo; font-size: 11px;" class="">RecoverableError</span> is a protocol in the standard library that can be implemented to opt in to the error recovery mechanism available on macOS. <span style="font-family: Menlo; font-size: 11px;" class="">attemptRecovery(</span><span style="font-family: Menlo; font-size: 11px;" class="">optionIndex, </span><span style="font-family: Menlo; font-size: 11px;" class="">resultHandler:)</span> is one of the methods that have to be implemented to conform to the protocol.</div><div class=""><br class=""></div><div class="">Here you can find the other ones:</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">/// Describes an error that may be recoverable by presenting several</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">/// potential recovery options to the user.</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">public</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">protocol</span><span style="font-variant-ligatures: no-common-ligatures" class=""> RecoverableError : </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Error</span><span style="font-variant-ligatures: no-common-ligatures" class=""> {</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// Provides a set of possible recovery options to present to the user.</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">public</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">var</span><span style="font-variant-ligatures: no-common-ligatures" class=""> recoveryOptions: [</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">String</span><span style="font-variant-ligatures: no-common-ligatures" class="">] { </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">get</span><span style="font-variant-ligatures: no-common-ligatures" class=""> }</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// Attempt to recover from this error when the user selected the</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// option at the given index. This routine must call handler and</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// indicate whether recovery was successful (or not).</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">///</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// This entry point is used for recovery of errors handled at a</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// "document" granularity, that do not affect the entire</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// application.</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">public</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> attemptRecovery(optionIndex recoveryOptionIndex: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">, resultHandler handler: (</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> Swift.</span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Void</span><span style="font-variant-ligatures: no-common-ligatures" class="">)</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal; min-height: 13px;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""></span><br class=""></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// Attempt to recover from this error when the user selected the</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// option at the given index. Returns true to indicate</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// successful recovery, and false otherwise.</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #008400" class="">///</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// This entry point is used for recovery of errors handled at</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// the "application" granularity, where nothing else in the</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// application can proceed until the attempted error recovery</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""> </span><span style="font-variant-ligatures: no-common-ligatures" class="">/// completes.</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">public</span><span style="font-variant-ligatures: no-common-ligatures" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #ba2da2" class="">func</span><span style="font-variant-ligatures: no-common-ligatures" class=""> attemptRecovery(optionIndex recoveryOptionIndex: </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Int</span><span style="font-variant-ligatures: no-common-ligatures" class="">) -> </span><span style="font-variant-ligatures: no-common-ligatures; color: #703daa" class="">Bool</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures" class="">}</span></div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;" class=""><br class=""></div><div class="">As you can see, there are two <span style="font-family: Menlo; font-size: 11px;" class="">attemptRecovery </span>methods. In my mind the first one was meant to be used for asynchronous operations, where you run some recovering code in background and then report its result back to the caller.</div><div class=""><br class=""></div><div class="">The problem is that the handler is not marked as <span style="font-family: Menlo; font-size: 11px;" class="">@escaping </span>and as such it can only be used inside the body of <span style="font-family: Menlo; font-size: 11px;" class="">attemptRecovery</span>. I was wondering if this was an oversight from the stdlib team or if this was a deliberate design decision.</div><div class=""><br class=""></div><div class="">I just saw that the method is still not marked as <span style="font-family: Menlo; font-size: 11px;" class="">@escaping</span> in master (<a href="https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/NSError.swift#L105" class="">https://github.com/apple/swift/blob/master/stdlib/public/SDK/Foundation/NSError.swift#L105</a>), so I’d like to know what its intended use case is, since the obvious one (asynchronous recovery) is prevented by the missing annotation.</div><div class=""><br class=""></div><div class="">Thanks,</div><div style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;" class=""><span style="font-family: Helvetica; font-size: 12px;" class="">Elia Cereda</span></div></div></div><div class="">
<br class=""><div class=""><blockquote type="cite" class=""><div class="">Il giorno 28 mar 2017, alle ore 17:33, Dennis Weissmann <<a href="mailto:dennis@dennisweissmann.me" class="">dennis@dennisweissmann.me</a>> ha scritto:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div dir="auto" class=""><div class="">Hey Elia,</div><div class=""><br class=""></div><div class="">I'm currently on mobile and don't really know what you're talking about (what is RecoverableError?) but you say it's a block, and if the closure is optional, it is @escaping by default.</div><div class=""><br class=""></div><div class="">Did you see <a href="https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160905/003185.html" class="">https://lists.swift.org/pipermail/swift-users/Week-of-Mon-20160905/003185.html</a><br class=""><br class=""><div class="">- Dennis<br class=""><div class=""><br class=""></div><div class="">Sent from my iPhone</div></div></div><div class=""><br class="">On 23. Mar 2017, at 10:07 AM, Elia Cereda via swift-users <<a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a>> wrote:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="content-type" content="text/html; charset=utf-8" class=""><div class="">I'd like to bump this issue, since it has been some time and it hasn't been addressed.</div><div class=""><br class=""></div><div class="">Thanks,<br class=""><div class="">Elia Cereda</div></div><div class=""><br class="">Il giorno 03 mar 2017, alle ore 21:33, Elia Cereda <<a href="mailto:eliacereda@gmail.com" class="">eliacereda@gmail.com</a>> ha scritto:<br class=""><br class=""></div><blockquote type="cite" class=""><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div class="">I’m wondering why the resultHandler block on RecoverableError.attemptRecovery(optionIndex, resultHandler:) is not marked @escaping?</div><div class=""><br class=""></div><div class="">I’m trying to invoke some recovering code that executes asynchronously, then reports if it was successful or not and I thought that this was the right strategy. As far as I can tell, without @escaping that method loses all it’s purpose and becomes essentially equivalent to attemptRecovery(optionIndex:).</div><div class=""><br class=""></div><div class="">So, I’d like to ask.</div><div class="">1. Is it a bug or that method is non-escaping on purpose?</div><div class="">2. If it is a bug, is there a workaround that can be applied pending a fix in a future version of Swift?</div><div class="">3. If it was a deliberate decision, what's the supported method of asynchronously invoking error recovery code?</div><div class=""><br class=""></div><div class="">Seeing that this wasn’t changed in Xcode 8.3b2, I think it unlikely that this was an oversight.</div><div class=""><br class=""></div>Thanks,<br class=""><div class="">
<div style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: 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="">Elia Cereda</div>
</div>
<br class=""></div></blockquote></div></blockquote><blockquote type="cite" class=""><div class=""><span class="">_______________________________________________</span><br class=""><span class="">swift-users mailing list</span><br class=""><span class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a></span><br class=""><span class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a></span><br class=""></div></blockquote></div></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-users mailing list<br class=""><a href="mailto:swift-users@swift.org" class="">swift-users@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-users" class="">https://lists.swift.org/mailman/listinfo/swift-users</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></div></div></blockquote></div><br class=""></body></html>