Making "super" work outside a literal?

Allen Wirfs-Brock allen at wirfs-brock.com
Fri Jun 24 13:00:57 PDT 2011


On Jun 23, 2011, at 11:12 PM, Brendan Eich wrote:

> On Jun 23, 2011, at 12:07 PM, Axel Rauschmayer wrote:
> 
> ...
> 
>>>> - Making "current function" available to a function does not incur costs? This is *not* an extra parameter, then?
>>> 
>>> Do you mean "current object", aka |here|?
>>> 
>>> If so, that's an extra parameter.
>>> 
>>> If not, I don't know what you mean.
>> 
>> Static super can only be accessed if you have a reference |thisFunction| to the function that is currently executed. I would think that  |thisFunction| would also incur costs, but Allen has since said that these costs are negligible.
> 
> The called function is part of the evaluation results needed to call the function. It is indeed passed on the stack in naive stack-based implementations, to support reflection (e.g. arguments usage by the callee; again remember the caller in general does not know whether the callee uses arguments, debugger, etc.), and debugging (kind of hyper-reflection).
> 
> In a JIT, the calling convention can use registers and avoid writing to memory more than the minimum needed based on whatever analysis the JIT can support.

I'm my response I was referring to the lexically bound function name from a function expression as the means to access the "current function".  That, presumably just uses the normal lexical addressing mechanism that is used to access any outer scope "variables".

> 
> In any event, there's no extra parameter beyond the situation in today's engines. With dynamic 'super', there is.
> 
> 
>> Related topic: How would |super| be handled if |this| is lexical?
> 
> There's no connection, AFAIK. But we also don't have a lexical-this proposal in Harmony yet.

If there was a mechanism for lexically addressing this, I would expect |super| to track |this| in parallel.  From a value perspective, |super| is just a synonym for |this|.

Allen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110624/94f6430c/attachment.html>


More information about the es-discuss mailing list