Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^3: Using closures to achieve data hiding in OO Perl

by demerphq (Chancellor)
on Jun 13, 2009 at 11:26 UTC ( [id://771218]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Using closures to achieve data hiding in OO Perl
in thread Using closures to achieve data hiding in OO Perl

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

  • Comment on Re^3: Using closures to achieve data hiding in OO Perl

Replies are listed 'Best First'.
Re^4: Using closures to achieve data hiding in OO Perl
by saurabh.hirani (Beadle) on Jun 15, 2009 at 04:45 UTC
    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.

    Thanks for the link. It looks interesting. Will definitely read it.

      Dont thank me for linking to it, thank dominus for writing it. Writing perl books is really really hard, and he did an absolutely outstanding job on it. Additionally if you ever get a chance to attend any kind of talk, or workshop or lecture or even just a beer with him then take it. It will definitely be worth it. He also has an excellent set of online resources: perl.plover.com

      ---
      $world=~s/war/peace/g

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://771218]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (6)
As of 2024-04-23 12:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found