promises-aplus / promises-spec

An open standard for sound, interoperable JavaScript promises—by implementers, for implementers.
https://promisesaplus.com/
Creative Commons Zero v1.0 Universal
1.84k stars 171 forks source link

Confused terminology: resolve and fulfill #223

Closed ryan-rowland closed 8 years ago

ryan-rowland commented 8 years ago

In 2.3, we seem to be defining resolution as the state transitioning out of pending, into fulfilled or rejected. However, in 2.3.3.3 we specify that the two callbacks supplied should be resolvePromise and rejectPromise. To my understanding, resolvePromise is actually deterministically fulfilling the Promise. Should these more accurately be named fulfillPromise and rejectPromise to closer match our definitions of fulfillment vs resolution?

This may appear to be a minor issue, but this recommendation seems to have guided MDN's documentation to suggest the following Promise callback names:

new Promise(function(resolve, reject) { /* ... */ });

Furthering my concern, I've recently had conversations with other Node.js & JavaScript developers that have suggested the community has moved away from the fulfilled terminology and onto the resolved terminology, which I can only attribute to MDN's misleading documentation.

I'd like to tighten up this terminology in this specification, creating a clear distinction between these terms, and ideally propagate said clarifications to MDN and any other documentation confusing these terms. What do you think, contributors?

petkaantonov commented 8 years ago

However, in 2.3.3.3 we specify that the two callbacks supplied should be resolvePromise and rejectPromise. To my understanding, resolvePromise is actually deterministically fulfilling the Promise.

in 2.3.3.3 resolvePromise does resolving the promise rather than fulfilling I.E. if the argument is a thenable/promise its value will become the fulfilled value (or rejection the rejection reason) rather than the promise. Fulfill takes whatever value as it is, without considering if it's a promise or thenable.

addaleax commented 8 years ago

I think the reason it’s called resolve its that you can pass a rejected Promise to resolve(), i.e. it does in fact not necessarily make the Promise fulfilled:

new Promise((resolve, reject) => {
    resolve(Promise.reject('ABC'));
})
// => rejected Promise with reason 'ABC'
ryan-rowland commented 8 years ago

Thank you for the clarification, guys. This makes perfect sense. I wasn't thinking about resolving with a rejected Promise.