That's a lot of extra lexicals that aren't being used in the closure. Does it carry them around?
That's easy to test:
#!/usr/bin/perl use strict; use warnings; sub DESTROY { print "DESTROY called!\n"; } sub make_accessor { my $self = shift; my ($name, $index) = (bless ([] => 'main'), 1); no strict 'refs'; *{ref($self) . "::$name"} = sub { my $self = shift; return $self->[$index] unless @_; $self->[$index] = $_[0]; $self; }; 1; } my $foo = make_accessor; print "End of program\n"; __END__ DESTROY called! End of program
So the answer is "no".
Abigail
In reply to Re: Closures and lexical scope
by Abigail-II
in thread Closures and lexical scope
by dragonchild
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |