I'm afraid that still wouldn't solve the problem; the superclass's code is all 100% completed before the subclass has `this` available.
On Fri, Aug 24, 2018 at 1:52 PM, Ranando King <[email protected]> wrote: > Aaron, congratulations! You just tripped over a new reason for me to > revive issue #123. The only way to get that to work is to have the default > values on the prototype. The problem comes because `this` doesn't even have > a value until the last call to `super()` returns. If a `class` doesn't have > a base `class` it essentially has Object as a base `class` and `super` is > implicitly called. So unless the default public field values are on the > prototype, there's literally no way to have them initialized before the > base classes are initialized. > > On Fri, Aug 24, 2018 at 3:15 PM Aaron Gray <[email protected]> > wrote: > >> I am having an issue with order semantics regarding https://github.com/ >> tc39/proposal-class-fields with derived classes defining or overriding >> data member values that are used in the base class constructor for >> initialization of properties of the class. >> >> This means the Super Class / Base Class'es constructor does not yet have >> access to the default field values of the derived class it is initiating. >> >> class Base { >> constructor() { >> .... >> .. idAttribute .. >> .... >> } >> idAttribute = 'id'; >> } >> class Derived extends Base { >> constructor() { >> super(); >> .... >> } >> idAttribute = '_id'; >> } >> >> All would mean having a separate initialize() function, but even this >> solution is flawed when there is a third level in the hierarchy. And as >> super() is required it means there seems to be no way round this issue. The >> only way I can see is some form of override keyword ? >> >> >> Has anyone got any solutions to this issue or work arounds ? >> -- >> Aaron Gray >> >> Independent Open Source Software Engineer, Computer Language Researcher, >> Information Theorist, and amateur computer scientist. >> _______________________________________________ >> es-discuss mailing list >> [email protected] >> https://mail.mozilla.org/listinfo/es-discuss >> > > _______________________________________________ > es-discuss mailing list > [email protected] > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

