A strawman for subclassing

David Bruant david.bruant at labri.fr
Mon Jun 13 17:08:30 PDT 2011


Le 14/06/2011 01:24, Allen Wirfs-Brock a écrit :
> On Jun 13, 2011, at 3:46 PM, David Bruant wrote:
>> Hi,
>>
>> The subclassing native constructor issue came out several times on the
>> list and on the web. However, I do not see a strawman for this. There
>> are strawman:array_create and strawman:array_subtypes, but no mention of
>> a generic solution.
> The <| operator is the proposed solution.
Oh ok, sorry, I hadn't read it yet. Thanks.

> Using <|  instances with arbitrary [[Prototype]] values can be created for any type built-in object type that has a literal representation.  that is functions, arrays, regexps, and less interestingly, strings, numbers, booleans.  The resulting instance all have the appropriate special internal behaviors that are associated with the built-in types.
It requires the right-hand side to have a specific initialization
syntax. It currently works for all the "classes" you cited ("functions,
arrays, regexps, and less interestingly, strings, numbers, booleans"),
but does not for the current harmony:simple_maps_and_sets for which
there is currently no specific syntax. Consequently, these could not be
subclassed (or I am missing something).
This would be the case for any other native "class" that wouldn't such
syntax. I'm not sure it's is viable in the long term because it will
require all subclassable (something people will want to subclass)
"classes" to have a syntax.

I like the idea of the <| operator, but a generic non-syntaxy solution
would be good too in my opinion. It would also allow people to subclass
host constructors (host objects with [[Construct]]).

David


More information about the es-discuss mailing list