Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Why are closures cool, continued?

by AidanLee (Chaplain)
on Jan 19, 2002 at 03:04 UTC ( #139987=note: print w/ replies, xml ) Need Help??


in reply to Why are closures cool, continued?

It really is a closure :)

The key is that the array @stuff are only supposed to exist while new() is the current scope. But by declaring a subroutine reference that uses @stuff you are forcing perl to not garbage-collect it at the end of new()'s scope. However, the only way you can now touch this array which is in limbo is through the subroutine reference which you returned from the subroutine new().


Comment on Re: Why are closures cool, continued?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (8)
As of 2014-08-22 21:04 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (165 votes), past polls