<div dir="ltr"><div>with consider defer statement</div><div>we can clean up the memory if coroutine is not completed.</div><div><br></div><div>i have updated the <span style="font-size:14px">proposal.</span></div></div><div class="gmail_extra"><br><div class="gmail_quote">2015-12-22 15:33 GMT+08:00 Andrew Bennett <span dir="ltr"><<a href="mailto:cacoyi@gmail.com" target="_blank">cacoyi@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Great proposal! I'm all for this, I think your proposed implementation is pretty good too.</div><div><br></div><div>It would be interesting to expand the proposal to consider more cases in more detail:</div><div> * Concurrency</div><div> * SequenceType versus GeneratorType<br></div><div> * Should a language feature depend on the Standard Library (GeneratorType)? Alternatives:<br></div><div> + func myFunction -> () -> T?</div><div> + func myFunction -> () -> (myFunction_State, myFunction_State -> T?)</div><div> * What happens if you write: guard ... else { yield ... }</div><div> * Use an enum for the state that encapsulates all possible variables in each state</div><div><br></div><div>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">https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20151207/001872.html</a><div><br></div><div>In particular you may be interested in Chris Lattner's comment:</div><blockquote style="margin:0px 0px 0px 40px;border:none;padding:0px">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>Either way it's worth discussing and working towards :)<br></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Dec 22, 2015 at 6:03 PM, Félix Cloutier <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><div>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><br></div><div>Generators are one use case, but resumable functions in general can also be used to make async code look prettier.</div><br><div>
<span style="border-collapse:separate;line-height:normal;border-spacing:0px">Félix</span>
</div>
<br><div><blockquote type="cite"><span><div>Le 22 déc. 2015 à 01:47:05, Susan Cheng via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>> a écrit :</div><br></span><div><span><div dir="ltr"><div>here is my proposal for swift lang</div><div><br></div><a href="https://github.com/SusanDoggie/swift-evolution/blob/master/proposals/0018-coroutine-for-swift.md" target="_blank">https://github.com/SusanDoggie/swift-evolution/blob/master/proposals/0018-coroutine-for-swift.md</a><br></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">
_______________________________________________<br>swift-evolution mailing list<br><a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br></div></blockquote></div><br>
<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">
</div>
<br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>
</div></div></blockquote></div><br></div>