News for hackers. Stuff that matters.
Re:Google Releases JavaScript.next to JavaScript Compiler Tr... by Sephr on Wednesday May 04, 2011 @12:01AM (#2512751)
You can actually combine generators with pseudo-deferred functions today in normal JavaScript 1.7+. For example, see async.js (https://github.com/eligrey/async.js). Disclaimer: I wrote the library.
Re:Google Releases JavaScript.next to JavaScript Compiler Tr... by joeshaw on Wednesday May 04, 2011 @10:10AM (#2513863)
gjs has something similar: http://git.gnome.org/browse/gjs/tree/modules/promise.js

You end up writing code like:

    function doAsyncStuff() {
        let result = yield someAsyncCall();
        result = yield someOtherAsyncCall(result);

        if (result) {
            Promise.putReturnFromGenerator("foo");
        } else {
            throw new Error("No result!");
        }
    }

    let promise = Promise.fromGenerator(doAsyncStuff);
    promise.get(function(result) {
        print(result); // -> "foo"
    }, function(error) {
        print(error); // -> exception toString() -> "No result!"
    });
The nice thing is the synchronous feel of doAsyncStuff() although it's actually pausing at each yield, waiting for a callback, and continuing execution from there.

It would seem as though Traceur's deferred functions replace the need for the generators by doing the continuation through the "await" keyword.