Generator return() and exceptions

Nathan Wall wwall at
Thu Jul 24 10:38:02 PDT 2014

Allen Wirfs-Brock wrote:
> So going back to my original questions. Given that we now have return()
> available to close an abnormally discarded generator, when would somebody
> (presumably implementing a control abstraction) actually want to apply
> throw() rather than return() to an iterator?

Sorry, I may be misunderstanding, but what about the use from Task.js?

var foo = async(function*() {
    throw 'from foo';

var bar = async(function*() {
    var promise = foo(),
    try {
        value = yield promise;
    } catch (e) {

The above should log "from foo".  Wouldn't `throw()` be needed for that?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list