Re: super() on class that extends

2015-04-11 Thread Erik Arvidsson
On Sat, Apr 11, 2015 at 9:09 AM Sébastien Cevey wrote: > Does the same apply to subclassing Error? > Subclassing Error works in V8 (Chrome 43). Caitlin, the only issue I know of in V8 regarding subclassing is subclassing Object and the weird wrapper we create. class X extends Object {} let x

Re: super() on class that extends

2015-04-11 Thread Sébastien Cevey
Does the same apply to subclassing Error? I've been trying to do that but it doesn't seem to work as expected, in particular passing the message as argument to `super` doesn't seem to do anything. For example: ``` javascript class Foo extends Error { constructor(message) { super(message);

Re: super() on class that extends

2015-04-10 Thread Allen Wirfs-Brock
> On Apr 10, 2015, at 10:54 PM, Allen Wirfs-Brock wrote: >> > > note totally true: err, “not" > > ```js > class SubArray extends Array { >constructor(…args) { > let newObj = new Array(…args); > newObj.__proto__ = SubArray.prototype; //or new.target.prototype > return ne

Re: super() on class that extends

2015-04-10 Thread Allen Wirfs-Brock
> On Apr 10, 2015, at 10:29 PM, Axel Rauschmayer wrote: > > No engine has implemented subclassing of `Array`, yet: > http://kangax.github.io/compat-table/es6/#Array_is_subclassable > > > And, as Sebastian mentioned, you can’t t

Re: super() on class that extends

2015-04-10 Thread Allen Wirfs-Brock
> On Apr 10, 2015, at 8:06 PM, Axel Rauschmayer wrote: > > ... > If you do not call `super()`, you only get into trouble if you access `this` > in some manner. Two examples: > > ... > > Therefore, there are two ways to avoid typing super-constructor calls. > > First, you can avoid accessing

Re: super() on class that extends

2015-04-10 Thread Caitlin Potter
> No engine has implemented subclassing of `Array`, yet: > http://kangax.github.io/compat-table/es6/#Array_is_subclassable > https://github.com/v8/v8-git-mirror/blob/master/test/mjsunit/harmony/classes-subclass-arrays.js

Re: super() on class that extends

2015-04-10 Thread Axel Rauschmayer
No engine has implemented subclassing of `Array`, yet: http://kangax.github.io/compat-table/es6/#Array_is_subclassable And, as Sebastian mentioned, you can’t transpile it, because it depends on the cooperation of `Array`: it beco

Re: super() on class that extends

2015-04-10 Thread Sebastian McKenzie
Babel is a terrible reference implementation for subclassing since it relies on the engine. See the docs http://babeljs.io/docs/usage/caveats/#classes and https://github.com/babel/babel/issues/1172 for more info. This exact question (super in derived class constructors) was also indirectly bough

Re: super() on class that extends

2015-04-10 Thread Garrett Smith
On 4/10/15, Axel Rauschmayer wrote: > The reason why you need to call the super-constructor from a derived class > constructor is due to where ES6 allocates instances - they are allocated > by/in the base class (this is necessary so that constructors can be > subclassed that have exotic instances,

Re: super() on class that extends

2015-04-10 Thread Axel Rauschmayer
The reason why you need to call the super-constructor from a derived class constructor is due to where ES6 allocates instances – they are allocated by/in the base class (this is necessary so that constructors can be subclassed that have exotic instances, e.g. `Array`): ```js // Base class class

Re: super() on class that extends

2015-04-10 Thread Kyle Simpson
Neither the base (parent) nor derived (child) class requires a constructor, nor does the child class require a `super()` call. If you omit either constructor, an assumed one is present. However, if you *do* declare a constructor in a derived class, you'll need to call `super()` in it. So, to th

super() on class that extends

2015-04-10 Thread Jacob Parker
Why was this a requirement? I have a class, we’ll call a, which I want to extend from b, but I don’t want to call the constructor. I just want to inherit a few functions from it. ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.or