-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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: Add Yield, CreateIteratorFromClosure, CreateAsyncIteratorFromClosure abs op. #2045
Conversation
How is this normative? It seems purely editorial. |
Is this meant to be useful for existing iterator-producing methods and the iterator helpers proposal? |
The plan for iterator helpers is to not have an actual generator function exposed to users, and i assume the same would be true for range. The intention is for each thing to be a normal function (just like all the existing iterator producers) that internally calls an abstract operation that’s implemented with generator spec mechanics. |
@ljharb rewrited |
I'll be most interested to see this technique used to non-observably improve the way, for example, String.prototype.matchAll is specified. |
Can the current PR do that? |
I feel pretty strongly that the current PR must do that, since we don't generally add abstract operations that have zero uses :-) |
I'll try to convert some existing algorithms later to verify my idea |
I found it is not easy to move to CreateBuiltinGeneratorFunction cause they have their own prototype, the next method that does the brand checking. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is very interesting, I think I'm going to like it a lot.
It'd be great to convert a few more builtins to get a feel for how that would work - perhaps matchAll, Array, and Map or Set?
how's that going? 🙈 @ljharb |
@Jack-Works it needs further editor call discussion; hopefully we can update this week. |
@Jack-Works hi! we discussed this, and we'd love to see more examples of iterator-producers converted to use this spec text. In particular, https://tc39.es/ecma262/#sec-string.prototype.matchall, https://tc39.es/ecma262/#sec-array.prototype.keys, and https://tc39.es/ecma262/#sec-map.prototype.keys. |
This isn't the design we're planning to use for iterator helpers, so I'm not sure how useful it would be to merge it in its current form. |
The design in this PR is learned from the iterator helper's current spec. I try to formalize words like
and I need to support the current built-in generator-like methods behavior too. My design work in the following way:
If there is any design not compatible with the iterator helper, please point out and I'll try to fix that, thanks! @devsnek |
done! 👀 |
@Jack-Works we're not using prelude and body steps anymore. Here's an example of what we have atm, though its not final: |
Is there specific reason to use the new form you screenshotted instead of the old form? |
@Jack-Works we had pushback against exposing the functions directly and pushback against the "prelude"/"body" pattern. |
LGTM, I'll adjust the design to match the style you posted later. |
Why the linter didn't tell me it failed at which line instead of this confusing message... 🤦♂️ Oh okay I have a syntax error here. |
Looks pretty good! There's a couple of small correctness things and a couple of small editorial issues which should get fixed before landing, and it also needs a rebase. |
has updated to the mainstream by |
No, that's fine. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a couple of last formatting tweaks. Otherwise LGTM.
@Jack-Works this PR will need a rebase, as well - it has a merge conflict. |
This comment has been minimized.
This comment has been minimized.
…romClosure abstract ops (#2045)
Cool |
Introduce
Yield
andCreateIteratorFromClosure
,CreateAsyncIteratorFromClosure
in the spec to make it easier to define builtin generators.Diff: https://arai-a.github.io/ecma262-compare/?pr=2045