TJ... I once woke up from a nap in the middle of a saturday and solved a silly issue i was having with event bubbling/propagation... I had seen the solution in code as the last thing before I woke up. I tried it... and it worked. The point: never feel bad about waking up to code on the brain :)
Rick On Sun, Sep 6, 2009 at 5:38 AM, T.J. Crowder <t...@crowdersoftware.com> wrote: > > > > I think you need "this.nifty.$super.call(this, foo);" > > > > You don't, although that also works. > > Ack! Sorry, too early in the morning, hadn't had enough coffee. > > That does *not* work, because you always refer to the bottommost > subclass's nifty ("this.nifty" is always the bottommost function), so > you end up endlessly recursing. Wow that's an easy trap to fall into. > > No, it's either use the function's name unadorned, or use > arguments.callee and pay the performance penalty. Personally, I > prefer using the function's name. :-) > > -- T.J. :-) > > On Sep 6, 8:48 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote: > > Hi Allen, > > > > > I think you need "this.nifty.$super.call(this, foo);" > > > > You don't, although that also works. A named function's name is in > > scope within the function: > > > > function foo(bar) { > > alert(typeof foo); // Alerts "function" > > } > > > > However, I was thinking about anonymous functions this morning while > > waking up (pathetic, isn't it?) and realized that even if you don't > > use a named function, you can avoid arguments.callee with exactly the > > form you describe: this.nifty.$super.call(this, foo); I don't like > > the repetition of "this", but if you don't have time to switch > > everything over to named functions (I'm thinking of retrofitting > > efforts), it's a reasonable first step, and I assume (haven't tested > > it yet) still gets speed gains over arguments.callee. > > > > Will be posting a sample implementation (it's wonderfully simple, but > > there are a couple of edge cases around dynamic updates of classes) > > and tests ASAP, but I want to get some of the Prototype documentation > > issues sorted out first (transferring the old doc to the new format > > and updating), since that's more urgent. > > > > -- T.J. :-) > > > > On Sep 5, 2:46 pm, Allen Madsen <bla...@gmail.com> wrote: > > > > > > > > > > > var Thingy = Class.create({ > > > > > nifty: function nifty(foo, bar) { > > > > > nifty.$super.call(this, foo); > > > > > } > > > > > }); > > > > > > > It just ignores the function name and complains that 'nifty' is not > > > > > defined. This works: > > > > > I think you need "this.nifty.$super.call(this, foo);" > > > > > Allen Madsenhttp://www.allenmadsen.com > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Prototype: Core" group. To post to this group, send email to prototype-core@googlegroups.com To unsubscribe from this group, send email to prototype-core-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-core?hl=en -~----------~----~----~----~------~----~------~--~---