default constructors and implicit super() insertion

P T Withington ptw at
Fri Jun 22 15:11:46 PDT 2007

I've always wondered what the point of carrying over C++'s  
constructor syntax was. Doesn't Javascript only allow one  
constructor?  (Never been a fan of the fake multi-method constructor  
kludge myself).  If the constructor didn't have a different name in  
each class, you wouldn't have the problems you outline.  Cf.: (http://

On 2007-06-22, at 17:20 EDT, Peter Hall wrote:

> I can't see much about this on the wiki export, and it is barely
> touched on here:
> classes.html#superconstructor
> Two slightly related comments.
> Wouldn't it be logical for a default constructor to automatically have
> the same signature as the super-class constructor?
> Also, if a constructor is defined which has the same signature as the
> super constructor, and a call to super() is inserted automatically,
> wouldn't it make sense for super() to be passed the same arguments?
> In AS3, automatic super() is always called without arguments, which
> can result in compile errors. Likewise, if you do not specify a
> constructor, the default constructor always has zero arguments. The
> result is that I often find myself adding constructors that do nothing
> at all, but can be a lot of duplicated code, if there are many
> arguments.
> A common AS3 example is extending Error or Event, where you mostly
> want the constructors to be the same, for consistency, and the class
> may add no functionality at all:
> class MyEvent extends Event
> {
>      public function MyEvent(type:String, bubbles:Boolean=false,
> cancelable:Boolean=false)
>      {
>           super(type, bubbles, cancelable);
>      }
> }
> Peter
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at

More information about the Es4-discuss mailing list