constructor, super, and data members issue
Aaron Gray
aaronngray.lists at gmail.com
Fri Aug 24 20:15:02 UTC 2018
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20180824/25cd4f56/attachment-0001.html>
More information about the es-discuss
mailing list