async/await improvements

James Long longster at gmail.com
Wed Nov 12 16:30:44 PST 2014


On Wed, Nov 12, 2014 at 7:28 PM, James Long <longster at gmail.com> wrote:
> On Wed, Nov 12, 2014 at 7:24 PM, Tab Atkins Jr. <jackalmage at gmail.com> wrote:
>> Marking a function as "top-level" is just syntax sugar for calling
>> .done() on the returned promise.  (Assuming that .done() can forward
>> rejections to window.onerror.)  It might be useful, I dunno, but it
>> doesn't offer anything fundamentally new.
>>
>
> It would be syntax sugar for:
>
> (async function foo() {
>   var x = await bar();
>   var y = await baz();
> })().done();
>
> Imaging writing lots of async code, where there are lots of top-level
> async functions... that seems like a wild thing to impose on users.

But even better, if we have that syntax sugar the JS engine can
automatically throw from the point of the `await` that failed. Think
of it exactly like `Task.spawn` or `Promise.spawn` in current promise
libs.

I need to run for the night. I think we've each made our points though.


More information about the es-discuss mailing list