Syntactic Confectionery Delight | |
PerlMonks |
Re^3: Using closures to achieve data hiding in OO Perlby demerphq (Chancellor) |
on Jun 13, 2009 at 11:26 UTC ( [id://771218]=note: print w/replies, xml ) | Need Help?? |
I use closures all the time. But never explicitly for data hiding (although it can come as a byproduct). Closures especially when coupled with eval, makes for an extremely powerful approach to solving problems, optimizing, simplifying design, and providing encapsulation. Using closures you can basically avoid OO, and do things that are extremely inefficient to do via OO techniques (especially in perl where method calls are slow). In fact I'd argue that closures are generally speaking more useful than OO. Go and get yourself a copy of Higher Order Perl by dominus. Its one of the better Perl books out there, and its almost all about using closures. Note: I updated this node by changing the previous link to mjd to the correct dominus.
--- $world=~s/war/peace/g
In Section
Meditations
|
|