tamejs icon indicating copy to clipboard operation
tamejs copied to clipboard

return-based syntax

Open ThiefMaster opened this issue 12 years ago • 1 comments

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));

ThiefMaster avatar May 26 '12 14:05 ThiefMaster

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

jameskeane avatar Sep 12 '12 05:09 jameskeane