<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="">Hi Susan,<div class=""><br class=""></div><div class="">As I mentioned on your original pull request, coroutines are closely related to async and other concurrency forms. That entire space is out of scope for Swift 3, so we should wait until fall 2016 to pick up discussion on this and related topics.</div><div class=""><br class=""></div><div class="">-Chris</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Dec 22, 2015, at 12:16 PM, Andrew Bennett 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=""><div dir="ltr" class=""><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class="">Hi Daniel,</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""><br class=""></span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class="">I've heard many great things about goroutines, and I definitively think their advantages should be considered in the design of Swift's concurrency.</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""><br class=""></span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class="">I haven't used goroutines much so I may be incorrect, but I don't think they can be used to efficiently represent a generator like the proposal suggests.</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""><br class=""></span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class="">The generator described in the proposal has the following properties:<br class=""></span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""> * it is basically just syntactic sugar<br class=""></span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""> * new elements are generated lazily</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""> * the length doesn't need to be known at initialisation</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""> * it uses existing function syntax in the caller</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""> * it can all run on one thread</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""> * concurrency considerations may be limited to safely updating the state variable from more than one thread</span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class=""><br class=""></span></font></div><div class=""><font size="2" class=""><span style="background-color:rgba(255,255,255,0)" class="">Maybe goroutines can be equivalent if the compiler can optimise it down to a generator. This proposal is basically syntactic sugar to concisely define a generator. Goroutines probably aren't a concise replacement for that sugar.</span></font></div><div class=""><br class=""></div></div><br class="">On Wednesday, 23 December 2015, Daniel Valls Estella <<a href="mailto:daniel@upzzle.com" class="">daniel@upzzle.com</a>> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><br class=""><div class="">Ok,</div><div class=""><br class=""></div><div class="">But I think goroutines are not really threads (are faster and cheaper enought to make a diference) and channels are more like filedescriptors than signals, you stream data throught these.</div><div class=""><br class=""></div><div class="">Thanks for your answer!</div><div class=""><br class=""></div><div class="">Daniel<br class=""><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class=""><font size="3" class=""><br class=""></font></div><div style="font-family: Helvetica; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;" class="">Daniel Valls Estella · tel. 659.910.830 · <a href="javascript:_e(%7B%7D,'cvml','daniel@upzzle.com');" target="_blank" class="">daniel@upzzle.com</a></div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">El 22 des 2015, a les 11:50, Susan Cheng <<a href="javascript:_e(%7B%7D,'cvml','susan.doggie@gmail.com');" target="_blank" class="">susan.doggie@gmail.com</a>> va escriure:</div><br class=""><div class="">It's a little difference with goroutine. Go using threads and signal.<div class="">My implementation is following C# methods that MS staff tells me.<br class=""><br class="">Daniel Valls Estella <<a href="javascript:_e(%7B%7D,'cvml','daniel@upzzle.com');" target="_blank" class="">daniel@upzzle.com</a>> 於 2015年12月22日星期二 寫道:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="">I think it’s better to take as a reference the <b class="">Go</b> language and his <b class="">goroutines</b> and <b class="">channels</b>.<div class=""><br class=""></div><div class="">Not just to face these type of problems but also to take new architectural aproches to build software solutions.<br class=""><div class=""><div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><font size="3" class=""><br class=""></font></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><font size="3" style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px" class="">refs:</font></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><font style="font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;text-transform:none;white-space:normal;word-spacing:0px" class=""> </font></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><a href="https://tour.golang.org/concurrency/1" target="_blank" class="">https://tour.golang.org/concurrency/1</a></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><a href="https://tour.golang.org/concurrency/2" target="_blank" class="">https://tour.golang.org/concurrency/2</a></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><a href="https://tour.golang.org/concurrency/5" target="_blank" class="">https://tour.golang.org/concurrency/5</a></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><a href="https://youtu.be/f6kdp27TYZs" target="_blank" class="">https://youtu.be/f6kdp27TYZs</a></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><br class=""></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><br class=""></div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class="">What you think?</div><div style="line-height:normal;text-align:-webkit-auto;text-indent:0px" class=""><br class=""></div><div style="font-family:Helvetica;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">Daniel</div><div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class=""><font size="3" class=""><br class=""></font></div><div style="font-family:Helvetica;font-size:14px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:-webkit-auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px" class="">Daniel Valls Estella · tel. 659.910.830 · <a class="">daniel@upzzle.com</a></div>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><div class="">El 22 des 2015, a les 8:33, Andrew Bennett via swift-evolution <<a class="">swift-evolution@swift.org</a>> va escriure:</div><br class=""><div class=""><div dir="ltr" class=""><div class="">Great proposal! I'm all for this, I think your proposed implementation is pretty good too.</div><div class=""><br class=""></div><div class="">It would be interesting to expand the proposal to consider more cases in more detail:</div><div class=""> * Concurrency</div><div class=""> * SequenceType versus GeneratorType<br class=""></div><div class=""> * Should a language feature depend on the Standard Library (GeneratorType)? Alternatives:<br class=""></div><div class=""> + func myFunction -> () -> T?</div><div class=""> + func myFunction -> () -> (myFunction_State, myFunction_State -> T?)</div><div class=""> * What happens if you write: guard ... else { yield ... }</div><div class=""> * Use an enum for the state that encapsulates all possible variables in each state</div><div class=""><br class=""></div><div class="">If you're not familiar with it, there's another thread that discussed similar here:</div><a href="https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001872.html" target="_blank" class="">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001872.html</a><div class=""><br class=""></div><div class="">In particular you may be interested in Chris Lattner's comment:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px" class="">I’m very interested in this, but it is clearly out of scope for Swift 3. It should also be considered alongside whatever async/concurrency approach we tackle (likely in swift 4).</blockquote><br class="">Either way it's worth discussing and working towards :)<br class=""></div><div class="gmail_extra"><br class=""><div class="gmail_quote">On Tue, Dec 22, 2015 at 6:03 PM, Félix Cloutier <span dir="ltr" class=""><<a class="">swift-evolution@swift.org</a>></span> wrote:<br class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class=""><div class="">There's probably some additional work to do on the proposal document, but I would like to see coroutines in Swift too. The feature has been very successful in other languages like Python and C#, and unless I'm mistaken, work is being done to standardize it in C++.</div><div class=""><br class=""></div><div class="">Generators are one use case, but resumable functions in general can also be used to make async code look prettier.</div><br class=""><div class="">
<span style="border-collapse:separate;line-height:normal;border-spacing:0px" class="">Félix</span>
</div>
<br class=""><div class=""><blockquote type="cite" class=""><span class=""><div class="">Le 22 déc. 2015 à 01:47:05, Susan Cheng via swift-evolution <<a class="">swift-evolution@swift.org</a>> a écrit :</div><br class=""></span><div class=""><span class=""><div dir="ltr" class=""><div class="">here is my proposal for swift lang</div><div class=""><br class=""></div><a href="https://github.com/SusanDoggie/swift-evolution/blob/master/proposals/0018-coroutine-for-swift.md" target="_blank" class="">https://github.com/SusanDoggie/swift-evolution/blob/master/proposals/0018-coroutine-for-swift.md</a><br class=""></div>
</span><img src="https://u2002410.ct.sendgrid.net/wf/open?upn=iRI3beHTe3UxYAHTlV3lA38zIPfHMhyuRzgTmGKV6k7cXv8i0D9519DoK7KYHAZzDNERxafB1pe872Yhhmi-2BiyWxsAHedNi3wh4t89fT-2BKwnNGjs9DnBFwV5eBmT6fDCjciSJZI8IeZaYr0UgGPnYQEVopgJV1xozCPgVx1QMsXTqwKj8GReKDgqgfrW75KolAqOxHlNELRYO4sMeFmSxsguQIkEf4l8dL3CnbhvjmU-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class="">
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=pQw7h83fWt3LLbgkfL4TSUL0weaZnVFZxDe5GShw4uRNKnTGhJeGxonM5msZE9opXco5hFz-2FepMTWpqOJKwxo-2Fe2VIVN6mVOrF-2BaySWURX-2BPZVsXp943zQJP31RiLgQHnpSgAtVY9mOb2RSUc-2FH4BhtUrKfWxse4Yvsyqr2k8wpDc9XBkOOssTr9lEtGPAkjmAzuM5b-2BPWpODXHOcg7J8BK9kuIMAJmyZbwiu-2BC5qAQ-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
</div>
<br class="">_______________________________________________<br class="">
swift-evolution mailing list<br class="">
<a class="">swift-evolution@swift.org</a><br class="">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="">
<br class=""></blockquote></div><br class=""></div>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=AdkfTiApI80cNEyortTzHW0kAjxqiRekfpEJArOEyyqmj4DRJx3ooJIHhV9lkZZFHQGuvpvgJ07djNDDr2cbO55ipOSLSgPiqKL6f2al0u374ShmXDyxxYjmu15DYu5LcQMApCVA087QaLw2hnsJZhbDN-2Fy7dLsjtWNZtEUOGpNGAv14a87mB3JmoluyGczE1totvhAJl6rgjxcY-2FGfKZZLIq6GDCiqz267BKWGvDbg-3D" alt="" width="1" height="1" border="0" style="min-height:1px!important;width:1px!important;border-width:0!important;margin-top:0!important;margin-bottom:0!important;margin-right:0!important;margin-left:0!important;padding-top:0!important;padding-bottom:0!important;padding-right:0!important;padding-left:0!important" class="">
_______________________________________________<br class="">swift-evolution mailing list<br class=""><a class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></blockquote></div>
</div></blockquote></div><br class=""></div></blockquote>
<img src="https://u2002410.ct.sendgrid.net/wf/open?upn=RC5Cq0zAxCHc1sM9Uy3-2BojrrUAw-2F96zH69NULNHPvCu3zAKQCfMa3w2QykbEZu8idfPdMLbIXLbSm1b6SCR7vnJB-2FHiLxbYVFUNTgIlkKkM3cLfkVsdu775dpqiokFYnN8aQNwgZBP1kSDClAx1-2BYHEulvtaho9feEhs0Oz5afsf1Ykk-2BrLXPU8BPbJsMsuCqiWe7uzZLABmEgqZ-2B-2F5gCtvZAGzRkgn6px2Yhd45gRU-3D" alt="" width="1" height="1" border="0" style="height:1px !important;width:1px !important;border-width:0 !important;margin-top:0 !important;margin-bottom:0 !important;margin-right:0 !important;margin-left:0 !important;padding-top:0 !important;padding-bottom:0 !important;padding-right:0 !important;padding-left:0 !important;" 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></blockquote></div><br class=""></div></body></html>