Arguments in default constructors and implicit super()

Peter Hall peter.hall at memorphic.com
Tue Apr 15 05:40:09 PDT 2008


Some time last year I started a brief discussion about passing
arguments to super() in a constructor, when it is automatically
inserted. (https://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



More information about the Es4-discuss mailing list