return-based syntax #31

ThiefMaster opened this Issue May 26, 2012 · 1 comment

2 participants


It would be nice to have a return-based syntax to make async programming even more comfortable.

function foo(host) {
    await dns.resolve(host, 'A', defer(var err, ip));
    return ip;

var ip = await foo('');

Implementing it should be rather easy since all the preprocessor has to do is transforming the code like this before performing whatever it already does:

function foo(host, cb) {
    await dns.resolve(host, 'A', defer(var err, ip));

await foo('', defer(var ip));

Then how do you actually return something from an async function. i.e. promises?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment