- From: Cameron McCormack <cam@mcc.id.au>
- Date: Thu, 08 Aug 2013 13:19:03 +1000
- To: Allen Wirfs-Brock <allen@wirfs-brock.com>
- CC: Anne van Kesteren <annevk@annevk.nl>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Allen Wirfs-Brock wrote: > The array subclassing issues have been solved. See > http://wiki.ecmascript.org/lib/exe/fetch.php?id=meetings%3Ameeting_jan_29_2013&cache=cache&media=meetings:subclassing_builtins.pdf > <http://wiki.ecmascript.org/lib/exe/fetch.php?id=meetings:meeting_jan_29_2013&cache=cache&media=meetings:subclassing_builtins.pdf> > In particular the first half of that deck. > > When you subclass via the ES6 class declaration (or you can wire it up > yourself) it does more than just make the subclass prototype inherit > from the superclass prototype. It also, via the inherited @@create > method, causes subclass instances to be allocated in the same manner as > the superclass instances. That means that instances of a subclass of > Array are actual exotic array objects. They use the same > [[DefineOwnProperty]] internal method as Array instances and handle the > "length" property in the same special way. Also, Array.isArray answers > true for such subclass instances because Array.isArray is actually a > test to see if an object is an exotic array object. Of course, a > subclass of Array can explicitly over-ride the inherited @@create method > in which case the instance might not allocated as an exotic array object > and none of this will be true. That is great news. For Web IDL, if this is a feature that is needed soon, we could just allow interface Elements : Array { ... }; where "Array" would be treated as being pre-defined. And we need to have interface objects defined in terms of ES6 classes (which is something that needs to be done anyway) so we get the inherited @@create method. If this is not a feature that is needed soon, then we should maybe consider it as part of the (yet to be had) discussion on what to do with Web IDL and JSIDL in the future.
Received on Thursday, 8 August 2013 03:19:49 UTC