On Dec 9, 2013, at 9:28 AM, James Long wrote:

> I read Allen's email wrong, thought it implied `this` was lexically
> scoped (which I know is not true. very little sleep at an airport...).
> 
> I'll keep digging through the spec, but if someone has a quick example
> what ES5 code I could compile to for roughly the same semantics, that
> would be helpful. From what I understand, you're saying that `super`
> is lexically scoped to the `class` that is defined so I can statically
> compile it out to something like `Foo.prototype.method` if `Foo` is
> the parent class. Anyway, no need to trail on about this, I should
> just RTFS

For an instance method defined in a class definition, [[Home]] is the instance 
prototype object defined by the class.  For a static method defined in a class 
definition [[Home]] is the class object (ie, the constructor function) itself.

super is not equivalent to a static reference to the super class or super class 
prototype be super must remain sensitive to prototype chain changes performed 
using Object.setPrototypeOf()

One way you can approximate [[Home]] in ES5 is to create a __Home property on 
the function objects that represent  methods.  Because [[Home]] never changes 
the __Home property could be non-writable, non-configurable.

At the last TC39 meeting there some decisions made about the use of super 
outside of class definitions.  Those decisions are not yet reflected in the ES6 
draft.

Allen


_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to