> On Mar 30, 2015 10:54 AM, Axel Rauschmayer <[email protected]> wrote:
> >>>
> >>> ```js
> >>> class MySuperClass {}
> >>>
> >>> // This function assumes that MySuperClass is an ES5 constructor function
> >>> function MySubConstructor(foo) {
> >>> MySuperClass.call(this);
> >>> this.foo = foo;
> >>> }
> >>> MySubConstructor.prototype = Object.create(MySuperClass.prototype);
> >>> MySubConstructor.prototype.constructor = MySubConstructor;
> >>> ```
> >>
> >>
> >> so if MySuperCall didn’t have the throw on [[Call]] behavior the above
> >> would work just fine.
> >
> >
> > In general, I’d expect this kind of subclassing to fail, due to the new
> > instantiation protocol. Wrong?
>
> Would work fine if throw semantics removed and invoked as
> ```js
> new MySubConstructor();
> ```
> Just like ES5.
>
> If invoked as
> ```js
> MySubConstructor();
> ```
> would fail just like ES5.
>
> Throwing on [[Call]] is a compatibility hazard.
>
Don’t the different assumptions as to where the instance is allocated ever
clash here? What if `MySuperClass` were:
```js
class MySuperClass extends Error {
}
```
--
Dr. Axel Rauschmayer
[email protected]
rauschma.de
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss