Reserving `await` within modules?

Kevin Smith zenparsing at gmail.com
Thu Mar 27 14:43:52 PDT 2014


>
>
> Could we reserve `await` inside the module grammar, so as to make it
> possible for future modules to await promises at top-level, without an
> IIAAFE? This would likely mean even web environments, with their very
> stringent backward-compatibility constraints, would be able to use this
> top-level `await`.
>

I don't think this will work given the staging that happens with module
loading/linking/etc.  But I have another option which I think will work
just fine:

    export async function main() {
      // your async code here
    }

If you export a main function and run that from the command line (e.g. node
my-module-with-main.js), the runtime executes the main module.  This takes
care of some other problems as well, like testing for whether or not the
module is executed as a program versus a library.

Maybe?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20140327/719f8d7e/attachment.html>


More information about the es-discuss mailing list