in reply to Re: closure clarity, please
in thread closure clarity, please
sub definitions are parsed once only. The closure retains the value it had at that point in time.
Yes, subs are only parsed once, but that's irrelevant.
The capturing occurs when the code ref is created. That's when the sub is defined for named subs, and that's when the sub op is executed for anonymous subs.
Furthermore, closures capture variables, not values. The value of the variable can be changed, from both inside and outside the sub.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: closure clarity, please
by BrowserUk (Patriarch) on Nov 24, 2009 at 07:27 UTC | |
by ikegami (Patriarch) on Nov 24, 2009 at 07:32 UTC | |
by BrowserUk (Patriarch) on Nov 24, 2009 at 17:08 UTC |