The `super` keyword doesn't work as it should?

/#!/JoePea joe at
Tue Jul 19 10:03:18 UTC 2016

Hi Bergi, yes, so the object that `super` references would work like
`this`, where the value is determined at runtime instead of in a
declaration. Basically, `super === Object.getPrototypeOf(this)` would
actually be true in my examples. It may be due to ["extra overhead"]( that `[[HomeObject]]` is only defined during
declaration, but that is at the huge expense of making the language less
intuitive and also more difficult to work with in some cases (for example,
in designing a multiple-inheritance scheme).

It would simply be great for super to just work as expected in the examples
I gave, which would mean that super would work in tandem and intuitively
with the various ways in which we can create objects-extending-objects in

Good news is that making the necessary change to `super` in ES8 or later is
completely backwards compatible with how it currently works.

I wonder what the performance problems are and if they can be solved.


On Mon, Jul 18, 2016 at 2:46 PM, Bergi <a.d.bergi at> wrote:

> /#!/JoePea wrote:
> Why can't `super` simply be a shortcut
>> for "look up the prototype of the object that the method is called on,
>> then
>> find the `.constructor` property and call it on `this`"? That seems to be
>> simple.
> Simple, yes, and broken in the case of multi-level inheritance:
> ```
> const x = Object.assign(Object.create({
>     method() {
>         console.log("parent");
>     }
> }), {
>     method() {
>         console.log("child");
>         Object.getPrototypeOf(this).method(); // super.method()
>     }
> });
> x.method(); // works as expected
> const y = Object.create(x);
> y.method(); // infinite loop/stack overflow
> ```
> A `super` query must not depend on `this` (only), it must statically
> resolve the object on which the called method is defined.
> In constructors, using the prototype of the currenctly called constructor
> for `super()` works well, but you'd need to use `Object.setPrototype` as
> there is currently no declarative way other than `class`es to define
> functions with custom prototypes.
> In methods, there would need to be a way to populate the [[HomeObject]]
> other than declaring the method as part of a class/object literal.
> Kind regards,
>  Bergi
> _______________________________________________
> es-discuss mailing list
> es-discuss at
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list