Making "super" work outside a literal?

Allen Wirfs-Brock allen at wirfs-brock.com
Wed Jun 22 02:28:54 PDT 2011


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()});

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.

Allen


More information about the es-discuss mailing list