Making "super" work outside a literal?

Sean Eagan seaneagan1 at gmail.com
Tue Jun 21 08:13:24 PDT 2011


On Tue, Jun 21, 2011 at 9:40 AM, Axel Rauschmayer <axel at rauschma.de> wrote:
>>> We wish to avoid another parameter computed potentially differently for each
>>> call. It will cost
>>
>> What costs do you foresee?  I am not sure that there is much to
>> compute.  Assume a method call O.m().  Assume "m" is found on an
>> object P within O's protoype chain.  This will result in P.m being
>> called, for which the "super binding" can simply be computed as
>> P.[[Prototype]].  Next assume a direct function call, e.g.
>> f.call(this) or f() (this === undefined), the "super binding" here
>> could just be calculated as this.[[Prototype]] or undefined if |this|
>> is not an object.
>
>
> This may already be what you are suggesting, so to clarify:
>
> I would introduce a binding called "here" that points to the object P where m has been found.
>
> - Method that uses super: compute super as here.[[Prototype]]
> - Non-method function that uses super: "here" is undefined, using super causes an error.
>
> If super is not used there is little computational cost! (Other than a binding per function call which may still be prohibitive.)

Regardless of any "here" binding, "super" would only need to be bound
within functions that actually use it (the same should be true for
|this|).  However, as I mentioned, it seems the cost of a dynamic
|super| binding should be relatively low, comparable to the cost of a
dynamic |this| binding.

>
> --
> Dr. Axel Rauschmayer
>
> axel at rauschma.de
> twitter.com/rauschma
>
> home: rauschma.de
> blog: 2ality.com
>
>
>
>



-- 
Sean Eagan


More information about the es-discuss mailing list