-
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
NewPromiseCapability & GetCapabilitiesExecutor Functions #392
Comments
Closely related to #355 |
And as before, people just seem confused. GetCapabilitiesExecutor is not an abstract operation, and having it return something would be pointless, since nobody cares about its return value. The entire point of NewPromiseCapability is to turn a constructor C into a record of { {[Promise]], [[Resolve]], [[Reject]] }, i.e. a PromiseCapability. So having it take resolve and reject arguments would defeat its purpose. And the reason for setting the [[Capabilty]] slot of the executor is so that the executor can set its [[Capability]]'s [[Resolve]] and [[Reject]], so of course they start out undefined. |
@domenic I believe that, it should be explained better in the spec. Every time I go through the spec I get confused at that point and looks like I am not the only one. |
I see now. I think the most confusing part is that the... section... is called GetCapabilitiesExecutor Functions. My mind was telling me that it was a getter that was supposed to create an executor. But it's not. The executor is never created, it just is. |
It's created in step 4 of NewPromiseCapability. |
Yep, but not in GetCapabilitiesExecutor, as the name suggests. |
Maybe it would be clearer if you thought of it as "ExecutorThatGetsCapabilities" |
👍 Yep, it would be even clearer if it was named that way. :) |
I think it's fine as-is naming wise but would accept a PR for a informative note regarding the purpose of this function. |
A class (or object) diagram would also be helpful, to get an overview of the entities that are involved in this part of the spec (PromiseReaction Record, PromiseCapability Record, Promise Reject Function, Promise Resolve Function, CapabilitiesExecutor Function, PromiseReactionJob, PromiseResolveThenableJob, Promise). |
The way GetCapabilitiesExecutor is used in NewPromiseCapability doesn't make sense to me.
First, there are some resolve and reject functions that are set as properties of the [[Capability]] slot of the executor that results from the operation. However, these resolve and reject functions are not passed as arguments in NewPromiseCapability. And, even if they were, in step 5 of NewPromiseCapability, the value of the [[Capability]] slot of the executor is replaced with the promise capability that was created in NewPromiseCapability, whose resolve and reject functions are undefined.
On the readability side, I think it would be an improvement to make GetCapabilitiesExecutor look more like other abstract operations: GetCapabilitiesExecutor(resolve, reject). And make it return F (the executor) instead of undefined. And explicitly pass resolve and reject from NewPormiseCapability.
The text was updated successfully, but these errors were encountered: