Why does legacy content break when making array-likes real arrays?

Allen Wirfs-Brock allen at wirfs-brock.com
Mon Dec 31 10:52:06 PST 2012


On Dec 31, 2012, at 10:39 AM, Brandon Benvie wrote:

> True, concat specifically needs to be changed. But it is the only Array method that does that check (the only other internal checks for brand BuiltinArray are in apply and isArray I think).

In support of Array subclassing, I have a tweak to concat that allows properly formed subclasses of Array to use concat and produce subclass instances while still preserving the current behavior for existing us3w.  I'll be ready to post the full details soon.

Allen








> 
> 
> On Mon, Dec 31, 2012 at 1:33 PM, Erik Arvidsson <erik.arvidsson at gmail.com> wrote:
> On Sun, Dec 30, 2012 at 6:05 PM, Brandon Benvie
> <brandon at brandonbenvie.com> wrote:
> > The primary issue is that most array-likes aren't array-like when it comes
> > to mutability. Most exposed indexed objects don't allow changes to their
> > indices, which is decidedly un-array-like for ~quarter of array operations.
> 
> The issue is not about the mutation methods even though it is non
> sensical to call push on an immutable array.
> 
> > It would be useful for there to be a separate "Indexed" class/prototype that
> > contained the Array methods that don't mutate `this`, which Arguments and
> > NodeLists and a bunch of other stuff could inherit from, which would also
> > prevent backward compat issues with testing for instanceof Array.
> 
> That would not help in the case with NodeList. The fix there would be
> to have concat not do a brand check on its arguments. Allen has
> outlined the problematic brand checks at
> http://wiki.ecmascript.org/doku.php?id=strawman:es5_internal_nominal_typing
> 
> 
> --
> erik
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20121231/5d28af93/attachment.html>


More information about the es-discuss mailing list