in reply to Re: Closures and scope of lexicals
in thread Closures and scope of lexicals
There is no block scope, variables live in a function or a file.
In order to create a list of closure functions in a loop closing over different variables - like in the OP's first example - one would need to call an explicit generator function, having the var in its scope and returning the closure.
Cheers Rolf
(addicted to the Perl Programming Language :)
see Wikisyntax for the Monastery
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Closures and scope of lexicals
by ikegami (Patriarch) on Oct 31, 2024 at 14:25 UTC | |
by LanX (Saint) on Oct 31, 2024 at 14:31 UTC | |
by ikegami (Patriarch) on Oct 31, 2024 at 14:35 UTC | |
by LanX (Saint) on Oct 31, 2024 at 14:37 UTC | |
by ikegami (Patriarch) on Oct 31, 2024 at 14:39 UTC | |
| |
by ikegami (Patriarch) on Oct 31, 2024 at 14:38 UTC |