Claude Pache <[email protected]>napísal/a:
For instance, if I wanted to support to be called through the legacy
`SuperConstructor.call(this, ...args)` trick in addition to be new’d, I'd
rather try the following:
constructor(x, y) {
if (new^)
this = new super(x);
else
super.constructor(x);
this.y = y;
}
Oh, this is really bulky.
Makes me think of fixing it by some slight magic. Like, adding modifier to
method deginition to say it is a constructor (new keuword before opening left
brace) and keeping stack of new^s in thread-local storage which wull be used in
new-tagged methods, even if [[Call]]ed.
But that is not a nice solution at all. :-/
The point here is that the purpose of the constructor method is not only
allocation, but also (and primarily) initialisation.
—Claude
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss