Promises Consensus

Claude Pache claude.pache at
Wed Jul 31 15:53:38 PDT 2013

Le 31 juil. 2013 à 20:23, "Tab Atkins Jr." <jackalmage at> a écrit :

> The first issue still up for community discussion involves the
> definition of "promise-like".
> We'd like the definition to be: (a) a Promise or subtype, or (b) a
> branded non-Promise (with the branding done via Symbol or similar).
> Promises/A+ wants the branding to be done via a method named "then"
> (the "thenable" concept).
> This, unfortunately, goes directly against TC39 practices in a number
> of other areas, such as iterators, where we don't want short string
> names as branding due to the possibility of collision.  (In the case
> of "then", collision isn't a possibility, it's a certainty - we *know*
> there are libraries out there today that put a "then" method on their
> objects without referring to Promises.)  Thoughts?

I suggest an @@isPromise builtin symbol, which works the same way as @@isRegExp in the ES6 spec [1]: An object is reputed to be a promise if and only if it has a property (either own or inherited) named @@isPromise. And `Promise.prototype` has initially an @@isPromise own property, so that instances of subclasses of `Promise` are recognised as promises.

(With this solution, you have not to choose between subclassing or branding, but you have the both. :-) )


[1] search the occurrences of @@isRegExp in:

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list