class Foo {}
Axel Rauschmayer wrote:
A case could be made that Foo.[[prototype]] should be Object and not Function.prototype. Then the prototype hierarchies of classes and their prototypes would be fully symmetric. The reason that isn’t done is so that a class is an instance of Function, right?
Yes, the class name binds to the constructor, which is a function. So there is no way that Foo.[[Prototype]] could be Object.prototype (is that what you meant?).
As for Object, that's ruled out for "class Foo {}" by design, to avoid class-side delegation polluting Foo with create, getOwnPropertyDescriptor, etc. If you want those, you have to say so: "class Foo extends Object {}".
On Jul 29, 2012, at 6:09 , Brendan Eich <brendan at mozilla.org> wrote:
Axel Rauschmayer wrote:
A case could be made that Foo.[[prototype]] should be Object and not Function.prototype. Then the prototype hierarchies of classes and their prototypes would be fully symmetric. The reason that isn’t done is so that a class is an instance of Function, right?
Yes, the class name binds to the constructor, which is a function. So there is no way that Foo.[[Prototype]] could be Object.prototype (is that what you meant?).
I was wrong about Foo not being an instance of a Function. I meant class Foo {} could be equivalent to class Foo extends Object {} (which you mentioned below). Then Foo.[[Prototype]] would be Object.
As for Object, that's ruled out for "class Foo {}" by design, to avoid class-side delegation polluting Foo with create, getOwnPropertyDescriptor, etc. If you want those, you have to say so: "class Foo extends Object {}".
Makes sense, thanks.
Axel Rauschmayer wrote:
I was wrong about Foo not being an instance of a Function. I meant class Foo {} could be equivalent to class Foo extends Object {} (which you mentioned below). Then Foo.[[Prototype]] would be Object.
As for Object, that's ruled out for "class Foo {}" by design, to avoid class-side delegation polluting Foo with create, getOwnPropertyDescriptor, etc. If you want those, you have to say so: "class Foo extends Object {}".
Makes sense, thanks.
As Rick's notes put it: "the clouds part and sun shining through, with angels singing from on high" when Dave heard Allen's rationale for why class Foo {} is not equivalent to class Foo extends Object {}. :-)
A case could be made that Foo.[[prototype]] should be Object and not Function.prototype. Then the prototype hierarchies of classes and their prototypes would be fully symmetric. The reason that isn’t done is so that a class is an instance of Function, right?
Axel