in reply to Re^5: Is it possible to create a sub exclusive to a sub? (nasty memory leak)
in thread Is it possible to create a sub exclusive to a sub?
&get_and_inc_foo is a closure, because it binds a lexical variable defined outside of it.
If my example is a closure, then aren't all subroutines closures over the file-scoped lexicals in the file they're defined in?
If they don't use any lexicals defined outside them, they're not closures. sub foo { 1 } isn't a closure no matter where it's defined.
What I mean with making the subroutine a lexical anonymous subroutine is the following.my $foo; sub closure { $foo } sub not_closure { 1 }
my $foo; # lexical $foo = sub { $foo->() }; # closure local $bar; # dynamical $bar = sub { $bar->() }; # not a closure
ihb
Read argumentation in its context!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^7: Is it possible to create a sub exclusive to a sub? (nasty memory leak)
by dragonchild (Archbishop) on Sep 19, 2004 at 18:30 UTC | |
by ihb (Deacon) on Sep 19, 2004 at 21:27 UTC |