<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="">To prove (or potentially disprove) my assertion that this is not just sugar, how would you accomplish the following under the current proposal?<div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let a = async longCalculationA()</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let b = async longCalculationB() //b doesn’t wait for a to complete before starting</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let c = async longCalculationC() //c doesn’t wait for a or b</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let result = await combineCalculations(a: a, b: b, c: c) //waits until a, b, and c are all available</div><div class=""><br class=""></div><div class="">(Note: this is using my version of async below which doesn’t use futures)<br class=""><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Aug 25, 2017, at 2:13 PM, Jonathan Hull via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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="">I actually <b class=""><i class="">really</i></b> like the idea of using ‘async' to start a computation in a non-blocking way. &nbsp;It is extremely common in real-world code to want to start a few computations/downloads at once in the background and then use the results together...<div class=""><br class=""></div><div class="">I think full-fledged futures could be a framework thing added on top, but what I would really love to see at the language level is that using ‘async’ just allows you to defer calling ‘await’. &nbsp;That is, you could get a value back from something called with async, but you would be forced to await that value before it could be used:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>var image = async downloadImage() &nbsp;//Image is type UIImage</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>//Do something else here</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let size = await image.size //The compiler forces me to call await before I can actually use the value</div><div class=""><div class=""><div class=""><br class=""></div><div class="">This looks somewhat similar to a future, but you can’t interact with it as a separate type of object. &nbsp;The value above is just a UIImage, but with a compiler flag/annotation that forces me to call await on it before it can be accessed/used. &nbsp;The compiler has a lot more freedom to optimize/reorganize things behind the scenes, because it doesn’t necessarily need to make an intermediate object.</div><div class=""><br class=""></div><div class="">I don’t think this is just sugar. &nbsp;It adds expressivity and control for a set of very common use-cases which aren’t fully supported by await alone.</div><div class=""><br class=""></div><div class="">Thanks,</div><div class="">Jon</div><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Aug 24, 2017, at 4:40 AM, Trevör ANNE DENISE via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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="">Hello Swift community,<div class=""><br class=""></div><div class="">I was really interested by the recent<i class="">&nbsp;Task-based concurrency manifesto</i>&nbsp;and&nbsp;<i class="">Concrete proposal for async semantics in Swift.</i></div><div class=""><i class=""><br class=""></i></div><div class="">Looking at beginAsync() and Futures, I had an idea for a new syntax based on the `async` keyword, I'd love to hear your feedback about this idea:</div><div class=""><a href="https://github.com/adtrevor/Swift-ideas/blob/master/New%20async%20keyword%20usage.md" class="">https://github.com/adtrevor/Swift-ideas/blob/master/New%20async%20keyword%20usage.md</a></div><div class=""><br class=""></div><div class="">Would such a syntax make any sense?</div><div class=""><br class=""></div><div class="">Thank you ! :)</div><div class=""><br class=""></div><div class=""><br class=""></div><div class="">Trevör</div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></div>_______________________________________________<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></blockquote></div><br class=""></div></div></body></html>