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

Editorial: Use Abstract Closure to set the code eval state #2681

Merged
merged 1 commit into from
Jan 11, 2023

Conversation

jmdyck
Copy link
Collaborator

@jmdyck jmdyck commented Mar 3, 2022

In GeneratorStart, AsyncGeneratorStart, and AsyncBlockStart, there is the following construct:

1. Set the code evaluation state of _context_ such that when evaluation
   is resumed for that execution context the following steps will be performed:
   1. <inner-steps>

This is a fairly novel construct, but we can reduce the novelty. Specifically, consider the <inner-steps>: they are to be performed later, but can refer to aliases defined in the outer algorithm. These are things that we see in Abstract Closures, so we can pull out those aspects of the construct:

1. Let _closure_ be a new Abstract Closure with no parameters
   that captures <aliases> and performs the following steps when called:
   1. <inner steps>
1. Set the code evaluation state of _context_ such that when evaluation
   is resumed for that execution context, _closure_ will be invoked.

(This has the side benefit of making the captures explicit.)

In this PR, the first commit makes the above change, and the second commit reduces the number of captured aliases by 'reconstructing' some of them within the closure.


I wasn't sure what to do about the [fence-effects="user-code"] annotation, but I'm guessing that ecmarkup's handling of Abstract Closures takes care of it. (Another side benefit.)


(There are also "Set the code eval state" steps in Await, GeneratorYield, and AsyncGeneratorYield, but I'm assuming that #2429 or #2665 will eliminate them.)

spec.html Outdated Show resolved Hide resolved
@michaelficarra michaelficarra added editor call to be discussed in the next editor call and removed editor call to be discussed in the next editor call labels Aug 8, 2022
Copy link
Contributor

@syg syg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, I like this use of ACs a lot.

@michaelficarra michaelficarra added the ready to merge Editors believe this PR needs no further reviews, and is ready to land. label Jan 11, 2023
... in GeneratorStart, AsyncGeneratorStart, and AsyncBlockStart.

 - fixup: Reduce the number of captured aliases
 - fixup: Change "invoked" to "called with no arguments"
@ljharb ljharb merged commit a71a200 into tc39:main Jan 11, 2023
@jmdyck jmdyck deleted the CES_closure branch January 12, 2023 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
editorial change ready to merge Editors believe this PR needs no further reviews, and is ready to land.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants