What I meant to say was, you didn't compare the first example of inlining to
another example using bind. I get that in general you were just illustrating
the closure behaviors...


Ryan Gahl
CEO
Nth Penguin, LLC
http://www.nthpenguin.com
--
Inquire: 1-920-574-2218
Blog: http://www.someElement.com
LinkedIn Profile: http://www.linkedin.com/in/ryangahl


On Wed, Mar 11, 2009 at 11:00 AM, Ryan Gahl <ryan.g...@gmail.com> wrote:

> If we recast our example to use a named function for the handler:
>>
>> function init() {
>>    var container;
>>
>>    container = $('container');
>>    hookUpHideables(container);
>>    container.show();
>>
>>    function hookUpHideables(p) {
>>        p.select('.hideable').invoke('observe', 'click', hideableClick);
>>    }
>> }
>>
>> function hideableClick(evt) {
>>    this.hide();
>> }
>>
>> ...no closures have outstanding references at the end of init(), and
>> the chain is eligible for GC.
>>
>
>  That's true, but your example does not use .bind(), therefore I don't
> really see how it pertains to the discussion. When you .bind(), you are
> passing the the function to bind, along with it's context and all that goes
> with that... so I really can't see how it's any better than inlining, except
> just on a pure convenience level. Keep in mind we're talking about cases
> where you need to "correct" the scope of the bound function so that "this"
> is your class's object instance. Your example here is a completely different
> scenario where the developer doesn't care that "this" is the element itself.
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to