Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Why are closures cool, continued?

by AidanLee (Chaplain)
on Jan 19, 2002 at 03:04 UTC ( [id://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().

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (2)
As of 2024-04-20 01:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found