super.apply(this, arguments)
Lars T Hansen
lth at acm.org
Thu Dec 20 07:10:40 PST 2007
Wiki rot. The construct method is long since obsolete.
The wiki really is wildly out of date in some respects. There is
nothing solid to replace it right now, but reading it can cause severe
confusion...
--lars
On Dec 20, 2007 2:57 PM, P T Withington <ptw at pobox.com> wrote:
> 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:
> >
> > http://wiki.ecmascript.org/doku.php?id=proposals:static_generics
> >
> > 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 pobox.com> 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 ...rest arg?
> >> _______________________________________________
> >> Es4-discuss mailing list
> >> Es4-discuss at mozilla.org
> >> https://mail.mozilla.org/listinfo/es4-discuss
> >>
> >
> >
> >
> > --
> > Monkey, so they say, is the root of all people today.
>
>
> _______________________________________________
> Es4-discuss mailing list
> Es4-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es4-discuss
>
More information about the Es4-discuss
mailing list