Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Re: Re (tilly) 2: Why Closures?

by dws (Chancellor)
on Apr 26, 2001 at 21:36 UTC ( #75836=note: print w/ replies, xml ) Need Help??


in reply to Re (tilly) 2: Why Closures?
in thread Why Closures?

I was under the impression that it was quite easy to write a function in Perl which expects some of its arguments to be functions, and then generates a new function to return.

Yes, you can build closures which hold other closures. Every once in a while I run into some bizarre situation where that is really, really useful.

Closures of closures can also be wickedly hard to debug.


Comment on Re: Re (tilly) 2: Why Closures?
Re (tilly) 4: Why Closures?
by tilly (Archbishop) on Apr 27, 2001 at 01:24 UTC
    As Tom Christiansen says, You can solve any programming problem with an extra level of indirection, except the problem of too many levels of indirection.

    A closure is a level of indirection. "I will take some action" but the action to take is defined elsewhere. When you start to layer levels of indirection, it becomes critical to know what each layer is supposed to do, and that each layer does its job absolutely correctly. This is true no matter what the layers of indirection are.

    However with closures it is easy to produce an astonishing number of layers of indirection in very little code. When you write a recursive function that generates closures out of closures, it basically has to work perfectly or it will do something totally bizarre...

    Caveat hacker. :-)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (3)
As of 2014-10-02 08:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    What is your favourite meta-syntactic variable name?














    Results (51 votes), past polls