Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for await and async #235

Open
velara3 opened this issue Dec 24, 2023 · 1 comment
Open

Support for await and async #235

velara3 opened this issue Dec 24, 2023 · 1 comment

Comments

@velara3
Copy link

velara3 commented Dec 24, 2023

The description from MDN:

The await operator is used to wait for a Promise and get its fulfillment value. It can only be used inside an async function or at the top level of a module.

Await is useful for calling and waiting for results from remote services and code readability.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/await#top_level_await

@hydroper
Copy link

Since ECMAScript 4 proposed generators without using a * prefix in function names unlike in ECMAScript Harmony, I suggest, please... maybe do not introduce the async modifier and comply with ECMAScript 4?

Not that it's difficult to parse, but it'd be nice to have a general consensus in the syntax, since ActionScript 3.0 implements most of ECMAScript 4.

ES4 examples:

/* methodThatYields(): Iterator.<Number> */

function methodThatYields(): Number {
    for (var i = 0; i < 10; i++) {
        yield i
    }
}

Example of asynchronous methods as in AS3Parser:

function asynchronousMethod1(): Promise.<Number> (
    Promise.resolve(10)
);
function asynchronousMethod2(): Promise.<Number> {
    return await asynchronousMethod1();
}

I've an implementation of Promise in my repository, as well (based on a polyfill), but I added a simple type parameter, so you may want to look at agera.util instead.

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

No branches or pull requests

3 participants