Skip to content

Redefine fromAsync as “built-in async function” #43

Closed
@js-choi

Description

@js-choi
Collaborator

After #36 was merged, Array.fromAsync spec now depends on tc39/ecma262#2942, just like proposal-async-iterator-helpers.

@bakkot points out that the current spec uses AsyncFunctionStart directly rather than defining Async.fromAsync as a “built-in async function”, which is a new concept defined by tc39/ecma262#2942. (The current spec version still does require tc39/ecma262#2942’s enhancement of AsyncFunctionStart.

We probably should define Async.fromAsync as a “built-in async function object”.

Note that tc39/ecma262#2942 (comment) suggests that the final form of tc39/ecma262#2942 might still not be completely settled.

Activity

js-choi

js-choi commented on Dec 2, 2023

@js-choi
CollaboratorAuthor

As far as I can tell, all this change requires is removing steps 1, 2, 3, 4, and 5, replacing them all with the sub-steps of step 3. tc39/ecma262#2942 seems to cause Array.fromAsync to implicitly be defined as a built-in async function object, whose [[Call]] method automatically creates a PromiseCapability and Abstract Closure, performs AsyncFunctionStart on them, and returns the resulting promise from PromiseCapability.

I will make a pull request for these changes after #44 is reviewed and merged.

[Edit 2025-04-05: Built-in functions also are able to automatically return Completion Records, so those can also be taken out.]

added theissue type on Apr 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @js-choi

      Issue actions

        Redefine fromAsync as “built-in async function” · Issue #43 · tc39/proposal-array-from-async