Arguments in default constructors and implicit super()

# Peter Hall (17 years ago)

Some time last year I started a brief discussion about passing arguments to super() in a constructor, when it is automatically inserted. (mail.mozilla.org/pipermail/es4-discuss/2007-June/000846.html)

The most common use-case from Flex/AS3 is probably for custom events, where you'd write something like:

class MyEvent extends Event { public function MyEvent(type:String, bubbles:Boolean=false, cancelable:Boolean=false) { super(type, bubbles, cancelable); } }

It would be nice if you could omit the call to super() and have automatically called with those argments. Or omit the constructor altogether and have it generated with the same signature as the super-class's constructor, passing on the arguments.

The last word from Brenden was :

Seems safe, helps what may be a common case (I don't know -- anyone with Flex experience have a count of classes this would help?).

I don't have a class count, nor a good idea of how to go about getting one, but I know this is common enough to make a difference at least to me and my team.

Peter

# Nathan de Vries (17 years ago)

On Tue, 2008-04-15 at 13:40 +0100, Peter Hall wrote:

The last word from Brenden was :

Seems safe, helps what may be a common case (I don't know -- anyone with Flex experience have a count of classes this would help?).

I don't have a class count, nor a good idea of how to go about getting one, but I know this is common enough to make a difference at least to me and my team.

My experience reflects yours. As an example, one of my projects (AS3 not Flex) is approximately 40,000 lines of code with 426 classes, of which 84 would benefit from an inherited constructor signature & an implicit call to super().

Cheers,

-- Nathan de Vries