super.apply(this, arguments)

P T Withington ptw at
Thu Dec 20 05:57:39 PST 2007

Interesting.  One wonders why we keep the silly fiction of naming the  
constructor after the class if it is really going to show up in the  
class as the `construct` method.  It's always bothered me that I have  
to write the class name in two places, and fix it in two places if I  
change my mind, or copy/paste a class to create a new class.

But, does the construct method cause allocation?  If so, it doesn't  
really solve my problem, since I really only want the initialization  
of the superclass constructor, not allocation.

It seems to me that what I really want is for there to be separate  
ways to apply `new` (to allocate a new instance using apply) and to  
apply the constructor method (to initialize a new instance using apply).

I want to be able to say:

class Foo extends Bar {

   function Foo () {
     super.initialize.apply(this, arguments);

I don't want to call `super.construct` because I don't want to  
allocate a new instance of my superclass, I just want to run the  
initialization that my superclass does.

I suppose I have to say:

     Bar.apply(this, arguments);

but now I have to type not only my class name, but also my superclass  
name in two places.

Or maybe we are going to be told this is yet another outdated wiki  
page that is leading us astray?

On 2007-12-20, at 00:02 EST, Garrett Smith wrote:

> There's a proposal that, I think, addresses that using construct:
> Though in the context of a subclass' constructor, I don't know what
> the syntax would be.
> Garrett
> On Dec 19, 2007 9:46 AM, P T Withington <ptw at> wrote:
>> Is this permitted syntax in a constructor:
>>   super.apply(this, arguments);
>> for the case where I want to pass all my arguments to my superclass
>> constructor?  If not, how does one do that, especially if the
>> constructor I am calling from takes a arg?
>> _______________________________________________
>> Es4-discuss mailing list
>> Es4-discuss at
> -- 
> Monkey, so they say, is the root of all people today.

More information about the Es4-discuss mailing list