Brendan Eich (2012-12-30T22:47:14.000Z)
Domenic Denicola wrote:
>> From: es-discuss-bounces at mozilla.org [mailto:es-discuss-bounces at mozilla.org] On Behalf Of Anne van Kesteren
>> Sent: Sunday, December 30, 2012 17:18
>>
>> On Sun, Dec 30, 2012 at 10:22 PM, Axel Rauschmayer<axel at rauschma.de>  wrote:
>>> 5. Array-like objects [not completely fixed (DOM...), but `arguments`
>> We've made some effort towards changing some of this, but legacy content is against us. :/
>
> I saw this happen, and was sad, but never understood what the legacy problem was.
>
> Similarly, when people ask me "why can't they just make arguments a real array" (perhaps with magic aliasing behavior in sloppy mode), I don't know the answer.
>
> So just out of curiosity, how does legacy code break when making array-likes into real arrays? I feel like the Liskov Substitution Principle should have our back here.

LSP is not magic. Works better when you have a type system.

The history of what went wrong is recorded here:

https://mail.mozilla.org/pipermail/es5-discuss/2009-August/003112.html

Read the followups. I'll cite Oliver's message in full below.

/be

-----


  Problem with Arguments inheriting from Array

*Oliver Hunt* oliver at apple.com 
<mailto:es5-discuss%40mozilla.org?Subject=Re:%20Re%3A%20Problem%20with%20Arguments%20inheriting%20from%20Array&In-Reply-To=%3C1701AFBF-C798-4A3C-B7F4-68ED492138DA%40apple.com%3E>
/Mon Aug 17 16:08:21 PDT 2009/

  * Previous message: JSON.stringify duplicate whitelist keys
    <https://mail.mozilla.org/pipermail/es5-discuss/2009-August/003111.html>
  * Next message: Problem with Arguments inheriting from Array
    <https://mail.mozilla.org/pipermail/es5-discuss/2009-August/003113.html>
  * *Messages sorted by:* [ date ]
    <https://mail.mozilla.org/pipermail/es5-discuss/2009-August/date.html#3112>
    [ thread ]
    <https://mail.mozilla.org/pipermail/es5-discuss/2009-August/thread.html#3112>
    [ subject ]
    <https://mail.mozilla.org/pipermail/es5-discuss/2009-August/subject.html#3112>
    [ author ]
    <https://mail.mozilla.org/pipermail/es5-discuss/2009-August/author.html#3112>


------------------------------------------------------------------------

I implement the logic to make the Arguments object inherit from Array
in WebKit last friday and it's quickly turned up a severe
incompatibility with Prototype.js, specifcally Prototype's isArray
function:
    isArray: function(object) {
      return object != null&&  typeof object == "object"&&
        'splice' in object&&  'join' in object;
    }
This breaks at the very least a number of Apple sites and Nasa.gov --
that's just two of the top row of sites onhttp://www.prototypejs.org/real-world
, other sites didn't appear to be broken but then i was merely looking
at loading the front page, nothing more.

Unfortunately the use of 'in' means we also can't just shadow a less
useful function with null or undefined for now.

Due to these site breakages, caused by a major compatibility problem
in a fairly major library it seems infeasible to attempt to retrofit
array like behaviour onto arguments.

--Oliver
github at esdiscuss.org (2013-07-12T02:26:06.466Z)
Domenic Denicola wrote:
> From: Anne van Kesteren
>
>> On Sun, Dec 30, 2012 at 10:22 PM, Axel Rauschmayer <axel at rauschma.de>  wrote:
>>> 5. Array-like objects [not completely fixed (DOM...), but `arguments`
>> We've made some effort towards changing some of this, but legacy content is against us. :/
>
> I saw this happen, and was sad, but never understood what the legacy problem was.
>
> Similarly, when people ask me "why can't they just make arguments a real array" (perhaps with magic aliasing behavior in sloppy mode), I don't know the answer.
>
> So just out of curiosity, how does legacy code break when making array-likes into real arrays? I feel like the Liskov Substitution Principle should have our back here.

LSP is not magic. Works better when you have a type system.

The history of what went wrong is recorded here:

https://mail.mozilla.org/pipermail/es5-discuss/2009-August/003112.html

Read the followups. I'll cite Oliver's message in full below.

---

Problem with Arguments inheriting from Array

Oliver Hunt oliver at apple.com /Mon Aug 17 16:08:21 PDT 2009/

I implement the logic to make the Arguments object inherit from Array
in WebKit last friday and it's quickly turned up a severe
incompatibility with Prototype.js, specifcally Prototype's isArray
function:

```js
    isArray: function(object) {
      return object != null && typeof object == "object" &&
        'splice' in object && 'join' in object;
    }
```

This breaks at the very least a number of Apple sites and Nasa.gov --
that's just two of the top row of sites onhttp://www.prototypejs.org/real-world
, other sites didn't appear to be broken but then i was merely looking
at loading the front page, nothing more.

Unfortunately the use of 'in' means we also can't just shadow a less
useful function with null or undefined for now.

Due to these site breakages, caused by a major compatibility problem
in a fairly major library it seems infeasible to attempt to retrofit
array like behaviour onto arguments.

--Oliver