in reply to Re^4: Closure on Closures (beta)
in thread Closure on Closures
So is this a closure?
Uhm, yeah... at least to the same extent that my example was.
The variable bindings are not retained - because we don't get 100, 101, etc.
The binding are only retained after the first entry via the goto, at which point, the variable does increment with each successive jump back to that code.
It behaves strangely. After the first jump into the code, it begins acting like a closure; the variable binding is retained. It isn't useful, in part because there is no easy way to initialize the variable first. Perl seems to initialize it to undef for us. I'm not even sure that this is the behavior I'd like to see. I figure it should either maintain the binding and act just like a named closure, or it should emit an error/warning. As it is, it works silently under strict checking and with warnings on.
-sauoq "My two cents aren't worth a dime.";
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^6: Closure on Closures ("a")
by tye (Sage) on Dec 16, 2011 at 19:18 UTC | |
Re^6: Closure on Closures (beta)
by adrianh (Chancellor) on Jul 08, 2003 at 06:42 UTC | |
by sauoq (Abbot) on Jul 08, 2003 at 16:39 UTC |