Making "super" work outside a literal?

Brendan Eich brendan at
Tue Jun 21 13:55:54 PDT 2011

On Jun 21, 2011, at 11:53 AM, Brendan Eich wrote:

> On Jun 21, 2011, at 11:33 AM, Oliver Hunt wrote:
>> I'm answering some of the performance questions in this, but i don't know what the intended semantics of 'dynamic super' would be so I can't give specific details of most of the use cases.  If it's essentially sugar for => Object.getPrototypeOf(this).foo (with appropriate munging for calls, etc) then the cost is at point of use only, but if it's anything more fun (there are references to additional implicit parameters below which would be fairly bad for performance of calls)
> That's the point: super must mean something other than Object.getPrototypeOf(this). Otherwise with the prototypal pattern you will infinitely recurse calling the same prototype-homed foo from foo via


C.prototype = {
  foo() { addedValue(); return; }

x = new C;;   // oops, diverges in endless self-recursion.

Now, with the static 'super' semantics plus Object.defineMethod(O, 'foo',, you can rebind 'super'.

One thing I'm not sure about: whether Object.defineMethod should mutate's internal property, or make a new function object with a different 'super' binding.

In any case, the static and internal-to-method semantics avoid the infinite recursion hazard, and they avoid the cost of an extra parameter beyond |this|.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the es-discuss mailing list