-
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
Better closures, or promise-handling, in the spec #933
Comments
I like upon-fulfillment and upon-rejection a lot (with "closures"). How frequently are the others coming up in Async Iteration work? What is the concern with omitting the "closing over" clause? The default assumption of "indented steps see outer named aliases" seems fine. |
"a promise resolved with" is very frequent. The others less so... I was thinking "transforming" would be used by Promise.prototype.finally or Promise.all, but I see those call the public API methods, so that doesn't quite work. And I guess it shouldn't; we should use proper closure machinery, possibly made simpler by (1), for closures that are actually exposed to author code.
I can't be sure, but I vaguely imagine it's to make you aware of the "cost" of the closure, and to make it easier to translate into languages (like C++) which don't have auto-capturing closures? I'd be OK omitting it. |
The spec uses the term "internal closure" for (roughly) an anonymous abstract op with access to 'outer' metavariables. Path (1) is proposing (roughly) an anonymous built-in function object whose call-semantics are given by steps with access to 'outer' metavariables. The spec should make it clear (via naming and description) that the two things are similar but distinct. |
Goodness, I had no idea that the spec had a notion of "internal closure" already. I see it is only used inside the notation of RegExp pattern semantics; strange. |
Yeah, there's a lot of strange stuff in RegExp semantics! |
Yeah, I was a bit confused at first by how the data passing in the RegExp spec works, though I imagine it's done that way because things would be very wordy if it were all explicit. Anyway, the RegExp usage of closures is pretty different from the Promise usage; it seems like they should be addressed separately. |
Over in the async iteration spec, we're having to write up more and more annoying "closures" as sections. Examples, from the current spec and from async iteration:
The vast majority of these are basically trying to respond to promises, running some spec steps in reaction to their fulfillment or rejection. (Those that are not: promise-rejection-functions, promise-resolve-functions, and proxy-revocation-functions.)
I would love to explore one or both of the following paths:
Example of (1)
CreateResolvingFunctions(promise)
When CreateResolvingFunctions is performed with argument promise, the following steps are taken:
Example of (2)
AsyncFunctionAwait ( value )
I am willing to spend significant time refactoring the current spec if I can get the go-ahead, for either (1) or (2) or both.
The text was updated successfully, but these errors were encountered: