Fixing `Promise.resolve()`

Allen Wirfs-Brock allen at
Thu Jun 11 01:00:59 UTC 2015

On Jun 10, 2015, at 9:16 AM, C. Scott Ananian wrote:

> On Wed, Jun 10, 2015 at 11:46 AM, Domenic Denicola <d at> wrote:
> Regardless of whether or not you agree, that was the original motivation for its introduction.
> says:
> ES6 final tweaks #8: Smalltalk-like species pattern used in Array methods, etc. to determine constructor for derived objects.
> discusses species in the context of `Array.prototype` methods.
> And says:
> Allen Wirfs-Brock: Smalltalk uses an abstract above that has a species property to determine what to create.
> That's all I know of it.  I wasn't there, obviously, and you were.  But this is the first I've ever heard of using @@species for constructor signature modification.  It's hard to reconstruct reasoning from meeting notes and tweets.

That's correct.  `species` is intended for use when a subclass constructor wants to use something other than itself as the constructor for objects derived from the subclass instances.  Using `species` to select a constructor higher in a class hierarchy for derived instances is a fine thing to so.  For example, a "SortedArray" might choose that operations like `map` should produce the more general Array instances rather than SortedArray instances.

Using `species` to modify constructor signatures was not one of its intended use-cases, however, it might be possible to use it for that purpose.

Note that the uses of `species` in the ES6 spec all assume that the signature of the returned constructor is the same as the base class constructor. 

However, a way around that might be to have a `species` method that was an adaptor of the expected constructor signature to some other signature pattern. 

For example, 
  LabelledPromise[Symbol.species] = function() {
       ctor = this;
       return function(executor) {
            if ( === undefined) throw TypeError("Can't call a class constructor");
            return Reflect.construct(ctor, [ctor.defaultLabel, executor],
LabelledPromise.defaultLabel = "default label";


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

More information about the es-discuss mailing list