On Tue, Jun 17, 2014 at 4:02 PM, Jason Orendorff <[email protected]> wrote:
> On Tue, Jun 17, 2014 at 2:49 PM, Jasper St. Pierre > <[email protected]> wrote: > > How would > > > > constructor() { > > if (rand() > 0.5) > > super("A"); > > } > > > > behave? > > SyntaxError. > > > We could prevent this behavior by making sure that super(); must be the > > first statement in a constructor, [...] > > That is what I proposed. > What does: class B { constructor(a) { this._a = a; } } class C extends B { constructor(b) { this._b = b; } } do? Some kind of compiler error? > [...] but that means that the subclass can't > > really influence the parent constructor execution at all. > > Any class can explicitly define a `static [Symbol.new]()` method, if > desired. > > Or the constructor method can return another object, so that the base > class @@new method is called, but the object it created is thrown > away. I should have mentioned that -- I would retain this behavior, > which is already in ES6, but none of the examples used it so I forgot > to say so. > > Anyway --- skipping a base class constructor is not a normal thing to > do. It shouldn't be the default. > > -j > -- Jasper
_______________________________________________ es-discuss mailing list [email protected] https://mail.mozilla.org/listinfo/es-discuss

