"Static" inheritance of builtins

Herby Vojčík herby at mailbox.sk
Sat Jan 28 12:54:55 PST 2012


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):
   TypeError.[[Prototype]] === Error,
   Error.[[Prototype]] === Object,
   Function.[[Prototype]] === Object,
   Number.[[Prototype]] == Object
etc.; and ultimately
   Object.[[Prototype]] === Function.prototype
? So that buitin constructor functions would have parallel hierarchy to 
their prototypes (as is nice for proper class to behave)?

Herby


More information about the es-discuss mailing list