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 
>> super.foo => 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 
> super.foo().

Example:

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

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


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

One thing I'm not sure about: whether Object.defineMethod should mutate 
C.prototype.foo'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|.

/be
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to