Brendan Eich wrote:
Brendan Eich wrote:
How about something like this?

spawn(function *() {
    var gen = this.thread;

    stream.on('data', function (data) {
          gen.send(data);
    });

    console.log(yield gen.next());
});

Sorry, a generator instance can't next itself, so that last statement should be:

console.log(yield undefined);

And in ES6 as amended, this should just be:

    console.log(yield);

Yield (after return, but return is a statement form, of course -- yield is an expression form due to send) can have an operand on its right, or no operand (meaning yield undefined). Cc'ing Allen to double-check that the spec will say so.

/be
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to