W3C home > Mailing lists > Public > public-script-coord@w3.org > October to December 2013

ArrayClass should imply @@isConcatSpreadable

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 28 Oct 2013 16:20:20 -0400
Message-ID: <526EC704.6050904@mit.edu>
To: "public-script-coord@w3.org" <public-script-coord@w3.org>
CC: es-discuss <es-discuss@mozilla.org>
As far as I can tell, the two places in ES5 that test [[Class]] being 
equal to "Array" are Array.isArray() and Array.prototype.concat.

In ES6, the former does some sort of brand check, but the latter calls 
IsConcatSpreadable, which checks for a @@isConcatSpreadable symbol.

It seems to me like we should probably have ArrayClass objects return 
true from the @@isConcatSpreadable symbol.

The benefit is that this makes ArrayClass objects quack as much like an 
array as we can, I think.

The drawback is that this perhaps makes it harder to add ArrayClass to 
existing objects...

In terms of existing ArrayClass objects that are shipping on the web 
right now, Gecko is shipping (though perhaps not in final releases yet) 
the .ports of a MessageEvent and the return value of getClientRects(). 
I _think_ changing the concat() behavior of these should be OK. 
Certainly for .ports, which we haven't been shipping for very long at all.


Received on Monday, 28 October 2013 20:21:05 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:19 UTC