Making "super" work outside a literal?

Brendan Eich brendan at mozilla.com
Wed Jun 22 03:42:05 PDT 2011


On Jun 22, 2011, at 2:28 AM, Allen Wirfs-Brock wrote:

> On Jun 21, 2011, at 9:55 PM, Brendan Eich wrote:
> 
>> 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.
> 
> I'm still thinking about this but I'm leaning towards specifying that defineMethod creates a new function and leave it up to implementations to optimize trivial cases where that is unnecessary like:
>   Object.defineMethod(obj, "foo", function () {super.foo()});

+1, or more


> Also, Object.defineProperty used to define a accessor property get or set function probably should also have this semantics.  Because 'super' is new that seems like an upwards compatible extension.

Yes.

/be


More information about the es-discuss mailing list