Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upBetter closures, or promise-handling, in the spec #933
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
bterlson
Jun 13, 2017
Member
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
domenic
Jun 13, 2017
Member
How frequently are the others coming up in Async Iteration work?
"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.
What is the concern with omitting the "closing over" clause? The default assumption of "indented steps see outer named aliases" seems fine.
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.
"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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
jmdyck
Jun 14, 2017
Collaborator
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
domenic
Jun 14, 2017
Member
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.
|
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. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Yeah, there's a lot of strange stuff in RegExp semantics! |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
littledan
Jun 15, 2017
Member
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.
|
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. |
domenic commentedJun 13, 2017
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.