On Feb 18, 2014, at 12:44 PM, C. Scott Ananian wrote:
>
>
> ps. I'm talking about this pattern in particular:
> ```js
> var SubPromise = function(exec) { Promise.call(this, exec); ... };
> Object.setPrototypeOf(SubPromise, Promise);
> SubPromise.prototype = Object.create(Promise.prototype);
> SubPromise.prototype.constructor = SubPromise;
> ```
> Note that `SubPromise` inherits `Promise.@@create` and so this code
> will work fine in an ES6 environment. (Blame @domenic, he showed me
> that this should work!)
Just to be clear, you're saying that the above would work in ES5 with a
polyfill implementation of Promise. Right?
It wouldn't work in an implementation where Promise was natively implemented
according to the ES6 Promise spec but where 'new SubPromise(exec)' did not
include a call to SubPromise.@@create. It might work if the native Promise
implementation diverged from the ES spec. and allowed Promise(exec) to be
equivalent to new Promise(exec) when the this value is not a built-in promise
object. But that would essentially be a non-standard extension that probably
couldn't be subsequently killed.
The purpose of standards for new features is to make sure that we don't have
divergence out of the gate so let's push our implementors to avoid creating
such divergence.
Allen
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss