return-based syntax #31

Open
ThiefMaster opened this Issue May 26, 2012 · 1 comment

2 participants

@ThiefMaster

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('github.com');

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));
    cb(ip);
}

await foo('github.com', defer(var ip));
@jameskeane

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