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 upMissing definitions for "<thing> equivalent to a function that <action>" #1077
Comments
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ljharb
Apr 1, 2018
Member
This phrase was actually added in ES2015: http://ecma-international.org/ecma-262/6.0/#sec-promisereaction-records
I copied that phrasing in the "finally" spec, but afterwards, I filed #584, which refactored the existing (definitionless) usage to be strings, instead of callbacks, stored in internal slots.
I think it'd be fine to add a definition, but ES2015 didn't seem to need one - what definition would you suggest and where would it go?
|
This phrase was actually added in ES2015: http://ecma-international.org/ecma-262/6.0/#sec-promisereaction-records I copied that phrasing in the "finally" spec, but afterwards, I filed #584, which refactored the existing (definitionless) usage to be strings, instead of callbacks, stored in internal slots. I think it'd be fine to add a definition, but ES2015 didn't seem to need one - what definition would you suggest and where would it go? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Apr 12, 2018
Contributor
That seems like a different case, because in ES2015 it was only used in a non-normative context whereas now it used for normative text.
|
That seems like a different case, because in ES2015 it was only used in a non-normative context whereas now it used for normative text. |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Fair enough :-) What definition would you suggest and where would it go? |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
anba
Apr 13, 2018
Contributor
The easiest fix is to create normal built-in functions à la:
Add:
25.6.5.3.1.1 Return Completion Functions
A Return Completion function is an anonymous built-in function that has a [[Completion]] internal slot.
When a Return Completion function F is called, the following steps are taken:
1. Return Completion(F.[[Completion]]).
The length property of a Return Completion function is 0.
And then replace:
- Let valueThunk be equivalent to a function that returns value.
With:
- Let stepsReturnCompletion be the algorithm steps defined in Return Completion Functions.
- Let valueThunk be CreateBuiltinFunction(stepsReturnCompletion, « [[Completion]] »).
- Set valueThunk.[[Completion]] to NormalCompletion(value).
And replace:
- Let thrower be equivalent to a function that throws reason.
With:
- Let stepsReturnCompletion be the algorithm steps defined in Return Completion Functions.
- Let thrower be CreateBuiltinFunction(stepsReturnCompletion, « [[Completion]] »).
- Set thrower.[[Completion]] to ThrowCompletion(reason).
And if we don't want to repeat the three steps to create this new function, it's also possible to add a helper like:
25.6.5.3.1.2 MakeReturnCompletionFunction(completionRecord)
The abstract operation MakeReturnCompletionFunction with argument completionRecord performs the following steps:
- Let stepsReturnCompletion be the algorithm steps defined in Return Completion Functions.
- Let F be CreateBuiltinFunction(stepsReturnCompletion, « [[Completion]] »).
- Set F.[[Completion]] to completionRecord.
- Return F.
And then use it like:
- Let valueThunk be MakeReturnCompletionFunction(NormalCompletion(value)).
- Let thrower be MakeReturnCompletionFunction(ThrowCompletion(reason)).
|
The easiest fix is to create normal built-in functions à la: Add: 25.6.5.3.1.1 Return Completion Functions A Return Completion function is an anonymous built-in function that has a [[Completion]] internal slot. When a Return Completion function F is called, the following steps are taken:
The length property of a Return Completion function is 0. And then replace:
With:
And replace:
With:
And if we don't want to repeat the three steps to create this new function, it's also possible to add a helper like: 25.6.5.3.1.2 MakeReturnCompletionFunction(completionRecord) The abstract operation MakeReturnCompletionFunction with argument completionRecord performs the following steps:
And then use it like:
|
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
A more ambitious fix would be to tackle #933. |
anba commentedJan 26, 2018
•
edited
Added in #1073