<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="">In terms of which functions need it, I think that reporting progress is a relatively niche feature. I would by far prefer that we work on infrastructure to implement a library-driven solution. To me, it would be a missed opportunity to show off what the language can (will be able to) do without having to bake it into the compiler.</div><div class=""><br class=""></div><div class="">For instance, this could probably be solved without specific compiler support if Swift had a macro system and resumable functions.</div><div class=""><div class=""><br class=""></div><div class="">Also, the first two arguments have merit, but it's highly improbable that you'll be able to use whatever solution we come up with in OSes older than OS X 10.11 or iOS 9 anyway.<br class=""><div class=""><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 18 janv. 2016 à 21:59:09, Charles Srstka via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; a écrit :</div><br class="Apple-interchange-newline"><div class=""><div class="">On 2016-01-18 21:12, Rob Mayoff via swift-evolution wrote:<br class=""><blockquote type="cite" class=""><blockquote type="cite" class="">1. Because NSProgress relies on a thread-local global variable to<br class="">store the current progress object, it is impossible to know, outside<br class="">of documentation, whether any particular method supports NSProgress<br class="">or not, and if the documentation is inadequate, one must resort to<br class="">trial-and-error to determine whether NSProgress is supported (this<br class="">has been noted before: <a href="http://oleb.net/blog/2014/03/nsprogress/" class="">http://oleb.net/blog/2014/03/nsprogress/</a><br class="">[1]).<br class=""></blockquote>iOS 9 and OS X 10.11 support explicit progress composition through the<br class="">addChild:withPendingUnitCount: message, and vending of an NSProgress<br class="">instance (for use with the addChild:withPendingUnitCount: message)<br class="">through the NSProgressReporting protocol. You no longer have to rely<br class="">on implicit composition, and in WWDC 2015 session 232 you're<br class="">encouraged to use explicit composition.<br class=""></blockquote><br class="">While this is technically true, 1) it is awkward, bloating method signatures by requiring you to add a "progress:" parameter to all of them, much like the NSError** pointers of old, 2) it doesn't solve the performance issues that NSProgress has with all of its KVO notifications being sent on the worker thread, and 3) you can't even use it, anyway, if you can't require OS X 10.11 or iOS 9.<br class=""><br class=""><blockquote type="cite" class="">I have a hard time believing this is something that needs dedicated<br class="">language syntax.<br class=""></blockquote><br class="">It's an incredibly common problem; almost every app that spawns a worker thread is going to need some way to report progress on the task, and a way to cancel it. The more primitive methods are written to support progress reporting, the easier it is for larger operations to report their own progress effectively, so it makes sense to introduce a mechanism that makes progress reporting as easy to implement as possible. I think this is what Apple was hoping for with the original NSProgress implementation; the implicit composition suggests an expectation that all code that does work would support NSProgress, and that you could just expect it. Sadly, that hasn't been the case, but by giving it first-class language support and making it dead easy to use, perhaps we could get closer to that point. At any rate, given Swift's focus on performance (and subsequently, the appropriateness of using pure Swift in a worker thread), it seems a shame to bog everything down with a low-performing progress API like what we have currently.<br class=""><br class="">Charles<br class=""><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class="">https://lists.swift.org/mailman/listinfo/swift-evolution<br class=""></div></div></blockquote></div><br class=""></div></div></div></body></html>