Matt, using closures to simulate "private" properties/methods has
actually been around for quite some time : ) (one of the most famous
examples is probably Crockford''s "module" pattern)
I actually found such technique almost essential when aiming for high-
performance appls. Not only it lets you "hide" certain logic, but also
allows to instantiate and cache most of the things before function is
ever run. As an example, take a look at an Object.forIn
implementation, where most of the "things" that actual method needs
are stored in a closure:
http://github.com/kangax/protolicious/tree/master/object.for_in.js
Best,
kangax
On May 12, 1:15 pm, Matt Foster
<mattfoste...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:> Hey Everyone,
>
> I found Kangax''s observable class and the function closure
used
> to create the instance and fell in love with the idea of easily
> created private methods. I''ve whipped up an article exploring
this
> idea in much more detail. Feel free to check it out
here,http://positionabsolute.net/blog/2008/04/prototype-class-inheritance.php
>
> --
> Matt Foster
> Ajax Engineer
> Nth Penguin, LLChttp://www.nthpenguin.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---