Making "super" work outside a literal?
brendan at mozilla.com
Sun Jun 26 09:29:44 PDT 2011
On Jun 26, 2011, at 3:05 AM, Allen Wirfs-Brock wrote:
> What property name would be be used in such implicit super calls? A function doesn't know what property name was used to access it.
In the languages and systems that have super()-only, a method always has a name.
So we could define "method that can use super" narrowly, as the new syntax in object initialiser, or in class body. IIRC you clarified that any nested function expression with such a method doesn't get the same super -- indeed gets undefined (I think; still some questions here related to |this| binding).
> Using an implicit property name in a super call would require that every method call implicitly pass the name used to access the property. This is just like the |here| problem.
No, not if the compiler sees the method name and burns it into the function object. Then it's just an internal property, analogous to static super. This is what engines do today with named function forms (definitions, named function expressions).
> On Jun 25, 2011, at 10:12 PM, Brendan Eich wrote:
>> On Jun 25, 2011, at 2:10 PM, Brendan Eich wrote:
>>> Should we really constrain super calls in methods to be only of the same-named method in the superclass? Conciseness is better but the restriction seems worse. Is it necessary in Ruby or CoffeeScript?
>> Consider also that the ES.next 'super' proposals allow super.baz where super.baz is a property other than a method. That would not be possible with 'super'-only.
>> es-discuss mailing list
>> es-discuss at mozilla.org
More information about the es-discuss