3 ms·
That is not true at all about Promises/A+. The requirement is to always calls handlers with an empty stack and in a certain order. In practice only naivest imp
by esailija 13y ago
That is not true at all about Promises/A+.
The requirement is to always calls handlers with an empty stack and in a certain order. In practice only naivest implementations would call platform scheduler for every `.then()`. Implementations can in all cases call the handlers synchronously when it would matter.
- quarterto 13y ago> In practice, this requirement ensures that onFulfilled and onRejected execute asynchronously, after the event loop turn in which then is called, and with a fresh stack. http://promises-aplus.github.io/promises-spec/#notes http://promises-aplus.github.io/promises-spec/#notes (emphasis mine)
- esailija 13y agoThat's just the specification. Doing exactly what the spec says is the definition of a naive implementation.
- delian66 13y agoWhat is the point of having a specification, if everyone decides not to follow it ?
- esailija 13y agoI did not say that one should not to comply to a specification. There is a big difference between implementations complying to specification and implementations where the source code is basically just duplication of the spec (which obviously runs very slowly). So my point is that even if the spec might say that "Do A, then B and then C", that's not what an implementation has to do EXACTLY as long as the outcome is exactly the same in both cases. For example a property load is a hugely complex operation in the ECMAScript spec that would take thousands of instructions to implement naively. In practice e.g. V8 will in many cases get away literally with one machine instruction in best case. None of the specified property load steps are obviously happening but yet somehow V8 is spec compliant.
- domenicd 13y agoNotice that's in the explanatory Notes section, not the normative Requirements section.