No such thing as a small change | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
That's a good example of using code refs, but it's not a closure. There are no private variables (unless I missed something there).
The anonymous routine (blessed or not) refers to a lexically-scoped variable in its enclosing scope. That lexically-scoped variable is magically kept alive (in the anonymous subroutine) after that enclosing scope has been exited. That is what makes an anonymous subroutine a closure.
Update: This is in agreement with perrin, btw. I'm just filling in some details...
In reply to Re: Re: (jeffa) Re: Why are closures cool, continued?
by dws
|
|