Allen Wirfs-Brock allen at wirfs-brock.com
Thu Dec 4 15:05:56 PST 2014

On Dec 4, 2014, at 2:25 PM, Domenic Denicola wrote:

> When implementing Array.prototype.includes for V8, we realized suddenly that we should probably do the same for typed arrays.

Of course!

> Looking at many of the %TypedArray%.prototype methods, it seems most of them are specified as basically "the same as Array, but with these minor tweaks." E.g.
> - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.fill
> - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.findindex
> - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.foreach
> A few though are specified in detail:
> - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.filter
> - https://people.mozilla.org/~jorendorff/es6-draft.html#sec-%typedarray%.prototype.map
> I was wondering if anyone knew why, so I can tell which to use as guidance for speccing %TypedArray%.prototype.includes?

Because some of the Array.prototype algorithms depend upon of the ability to an Array to dynamically grow its length or other characteristics that are not true of Typed Array instances. A new algorithm that is appropriate for a Typed Array implementation is specified for those cases. Otherwise, we just reference the Array.prototype algorithm. 

For 'includes', you probably can get array with using the same algorithm as Array.prototype.includes.

> As for process issues, I think it would be reasonable to add a supplement to the existing tc39/Array.prototype.includes repo tacking this on? Or would that be bad, and I should start a separate proposal?

Add it to the existing proposal.  It's an oversight that it wasn't included and something that should have been caught by reviewers if we were paying attention.  In general, we want Array and Typed Arrays to support the same set of methods.


More information about the es-discuss mailing list