in reply to Closures and lexical scope
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re2: Closures and lexical scope
by dragonchild (Archbishop) on Aug 27, 2003 at 17:32 UTC |