Making "super" work outside a literal?

Brendan Eich brendan at mozilla.com
Wed Jun 22 15:21:17 PDT 2011


On Jun 22, 2011, at 2:36 PM, Sean Eagan wrote:

> On Wed, Jun 22, 2011 at 2:10 PM, Brendan Eich <brendan at mozilla.com> wrote:
>>> Yes, functions have static scope, but functions (and all objects) do
>>> not have static owning objects,
>> The scope in ES1-5 can be an object, the global object. Your use of "owning" here either covers that case, in which your claim is false, or you need to define it better.
> 
> By "owning object" I mean an object which has the function (or
> arbitrary object) as one (or more) of its properties.  Regardless of a
> function's scope, it may have multiple owning objects, one of which
> may be the global object, as opposed to a single permanent (static)
> owning object.

This is all theoretical. In my experience, methods written either as function-valued properties in object literals, or goog.foo.bar = function (){} assignments, are the norm and there is only one "here" for each such method.


> Is there no per-call cost whatsoever to adding static super?

No, it's static -- an internal property of the function object set once on creation and (in my view) never changed thereafter unless unobservably (Allen's point about optimizing Object.defineMethod when "handing off" an otherwise-useless function expression).

/be


More information about the es-discuss mailing list