"Static" inheritance of builtins

Herby Vojčík herby at mailbox.sk
Mon Jan 30 01:45:10 PST 2012

"Only" from principal point of view. With new <| operator doing parallel 
hierarchy between functions (and hoping to get classes do the same, 
though if I didn't misread the proposal, extends does not do that; not 
to mention I dislike extends in favour of <| which already does that), 
the notion of "class inherits from superclass" will shift from 
"prototypes are in chain" to "% as well as constructors are". So, one 
inheriting from builtin class would presume they are in this kind of 
relationship as well.

If it does not break anything, it would be good to have. Maybe it can 
even bring some pluses, though I cannot say for now.


Allen Wirfs-Brock wrote:
> On Jan 28, 2012, at 12:54 PM, Herby Vojčík wrote:
>> Hello,
>> in ES, inheritance between "classes" was in fact only inheritance between their prototypes; the constructor functions always inherited from Function.prototype directly.
>> Now,<| operator defines that
>>   Fun<| function SubFun (...) { ... }
>> not only does parallel hierarchy so that
>>   SubFun.prototype.[[Prototype]] === Fun.prototype, but also
>>   SubFun.[[Prototype]] === Fun.
>> So constructor functions ultimately descend from Function.prototype, but it may be indirectly. "Subclasses" themselves also inherit "static" properites from their superclass.
>> Would it break things if this would be true for builtins, as well? So that (for example, not citing all):
> It would certainly be observable.  Whether is would actually breaking anything can only be speculated at this point until somebody tries it in a widely used implementation. My speculation is that no breakage would occur. Is this important enough to try?
> Allen

More information about the es-discuss mailing list