Skip to content

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

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

js-choi
Copy link
Collaborator

@js-choi js-choi commented Apr 5, 2025

This tweaks the spec to use the new “built-in async function” machinery in tc39/ecma262#2942. It resolves #43. See also #31, #36.

  • It uses the same “This async method performs the following steps when called” language as proposal-async-iterator-helpers.
  • It replaces returning Completion Records with direct returning of array values, which are now implicitly wrapped in Completion Records by the definition of built-in async function objects.
  • It removes the wrapping async Abstract Closure, which is now implicitly defined by the definition of built-in async function objects.
  • It tweaks the ending note to match the language in Array.from’s note.
  • It tweaks the spec location of IfAbruptCloseAsyncIterator to be “Operations on Iterator Objects” of “Abstract Operations”, to match IfAbruptCloseIterator. This is an editorial change.
  • It tweaks IfAbruptCloseAsyncIterator to assert that its given value is a Completion Record. This matches IfAbruptCloseAsyncIterator. This is an editorial change.
  • It adds an aoid attribute for IfAbruptCloseAsyncIterator. This is an editorial change.
  • IfAbruptCloseAsyncIterator now directly uses the return value of AsyncIteratorClose. This is an editorial change.
  • Editorial formatting changes have been done, e.g., avoiding unnecessary HTML entities and making if/else subclauses use blocks if any alternative branch uses blocks.
  • It lastly updates ecmarkup to v21.2.0 and ecma262-biblio to v2.1.2869.

This is the last step before creating a pull request to tc39/ecma262 (along with resolving the merge conflicts of tc39/ecma262#2942). We’re almost there.

@nicolo-ribaudo, @ljharb, since you reviewed it before for Stage 3 (#14), would you mind reviewing before we merge this?

@js-choi js-choi requested review from nicolo-ribaudo and ljharb April 5, 2025 06:36
The “Iterator Abstract Operations” subsection of “Iteration” from the
old version of proposal-iterator-helpers and
proposal-async-iterator-helpers is obsolete.

This means that the new IfAbruptCloseAsyncIterator operation (shared with proposal-async-iterator-helpers) no longer has a place to
live.

The ecma262 spec placed
proposal-iterator-helpers’ analogous IfAbruptCloseIterator operation
into a “Operations on Iterator Objects” subsection of “Abstract Operations”.

This commit places IfAbruptCloseAsyncIterator into an analogous
“Operations on Async Iterator Objects” subsection…although Async
Iterator Objects do not yet exist!

The editors may choose to name this new subsection whatever they want.
Or they might elect to not make a new subsection and foist
IfAbruptCloseAsyncIterator on the existing “Operations on Iterator
Objects” subsection instead, until proposal-async-iterator-helpers makes
Stage 4.

This is an editorial change.
@js-choi
Copy link
Collaborator Author

js-choi commented May 1, 2025

FYI, I pushed an editorial change to the new IfAbruptCloseAsyncIterator operation’s location.

The “Iterator Abstract Operations” subsection of “Iteration” from the old version of proposal-iterator-helpers and proposal-async-iterator-helpers is obsolete.

This means that the new IfAbruptCloseAsyncIterator operation (from #25, shared with proposal-async-iterator-helpers) no longer has a place in the spec to live.

The ecma262 spec placed proposal-iterator-helpers’ analogous IfAbruptCloseIterator operation into a “Operations on Iterator Objects” subsection of “Abstract Operations”.

This commit places IfAbruptCloseAsyncIterator into an analogous new “Operations on Async Iterator Objects” subsection…although Async Iterator Objects do not yet exist (coming in proposal-async-iterator-helpers)! the existing “Operations on Iterator Objects” subsection, which already contains several operations relevant to async iterables, such as AsyncIteratorClose.

The spec editors may choose to name this new subsection whatever they want. Or they might elect to not make a new subsection and foist IfAbruptCloseAsyncIterator on the existing “Operations on Iterator Objects” subsection instead, until proposal-async-iterator-helpers makes Stage 4.

Since this is a merely editorial tweak to the pull request, I don’t think the tweak deserves scrutiny until I make a pull request on tc39/ecma262#2942.

js-choi added 4 commits May 1, 2025 06:55
…ns on Iterator Objects”

This matches the spec’s use of “Operations on Iterator Objects” to
contain async iterable operations AsyncIteratorClose.
This matches ecma262’s IfAbruptCloseIterator.
* IfAbruptCloseAsyncIterator now directly uses the return value of   AsyncIteratorClose. This is an editorial change.
* Editorial formatting changes have been done, e.g., avoiding unnecessary HTML entities and making if/else subclauses use blocks if any alternative branch uses blocks.
@js-choi js-choi mentioned this pull request May 1, 2025
5 tasks
js-choi added a commit to js-choi/tc39-agendas that referenced this pull request May 5, 2025
Please note that the proposal-array-from-async proposal is out of date and still has a pending pull request (tc39/proposal-array-from-async#50). 

The most up-to-date version is the tc39/ecma262#3581 pull request linked in the table.
ljharb pushed a commit to js-choi/tc39-agendas that referenced this pull request May 6, 2025
Please note that the proposal-array-from-async proposal is out of date and still has a pending pull request (tc39/proposal-array-from-async#50).

The most up-to-date version is the tc39/ecma262#3581 pull request linked in the table.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Redefine fromAsync as “built-in async function”
2 participants