WebAssembly / WebAssembly/spec

[js-api] Possible alignment of abstract closure conventions with ECMA-262

Open
#2,027 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
WebAssembly
Stars
3.5k
Forks
539
Avg merge
2d 1h
Merged PRs (30d)
13

Description

In the JS-API specification, there are a few cases where abstract closures are used.
I was wondering if these could follow the same conventions as in ECMA-262 for consistency.

Image

React step in js-api specification

For example, in the algorithm “Instantiate a promise of a module”, there is a step called react.
This step takes as input some substeps to perform when the promise is fulfilled or rejected.
Each of these substeps is later passed to ECMA-262’s CreateBuiltinFunction, which expects an abstract closure as an argument.
In other words, the react step treats those substeps as abstract closures in the ECMA-262 sense.

However, the way these closures are represented in the JS-API specification looks quite different from the convention used in ECMA-262.

Image

Abstract closure in ECMA-262

Image

Abstract closure in WebIDL

In ECMA-262, abstract closures are explicitly marked as such, with their parameters and captured variables listed.
While the JS-API specification depends on the Infra Standard (which may justify stylistic differences), another Infra-based specification, WebIDL, also follows the ECMA-262 convention.

Would it make sense for the JS-API specification to adopt a similar notation, explicitly marking these substeps as abstract closures like below?
This could make it clearer that they correspond to ECMA-262 abstract closures and help maintain consistency across related specifications.
For example, it might be written as follows instead:

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in the JS-API specification with the “Instantiate a promise of a module” algorithm and its react step. Compare its substep notation with the abstract closure conventions shown from ECMA-262 and WebIDL, then identify the other affected cases. Done means the agreed closure notation is applied consistently across the relevant JS-API specification text.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
documentation
Issue type
Documentation
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.