Closed p5pRT closed 16 years ago
% perl -le '{ my $foo = 42; sub foo { sub { $foo } } } print foo->() + 0' 0
I expect the inner sub to use the current value of $foo. It's not being captured\, though.
On Sun\, Jul 08\, 2007 at 11:29:16PM -0700\, sthalik @ tehran. lain. pl wrote:
% perl -le '{ my $foo = 42; sub foo { sub { $foo } } } print foo->() + 0' 0
I expect the inner sub to use the current value of $foo. It's not being captured\, though.
This doesn't occur in blead.
Abigail
The RT System itself - Status changed from 'new' to 'open'
On 09/07/07\, via RT sthalik @ tehran. lain. pl \perlbug\-followup@​perl\.org wrote:
% perl -le '{ my $foo = 42; sub foo { sub { $foo } } } print foo->() + 0' 0
I expect the inner sub to use the current value of $foo. It's not being captured\, though.
That appears to be fixed with 5.9.5.
On Sun\, Jul 08\, 2007\, perlbug-followup@perl.org wrote:
Works in 5.9.4. Could you please merge it before the next stable version?
-- /\ Jabber ID :: sthalik@jabber.autocom.pl / Unix stuff :: http://tehran.lain.pl \ \/ Yet Another RBL :: http://rbl.lain.pl \/\ Web hosting :: http://insane.pl
Stanislaw Halik \<sthalik \
Works in 5.9.4. Could you please merge it before the next stable version?
This was part of Dave Mitchell's jumbo closure patch that was deemed by him unsafe for 5.8.x. (Dave\, please correct me if I'm wrong.) So expect it in 5.10.0 only.
The workaround is to introduce a mention of the lexicals you want to close over in the middle:
$ perl -le '{ my $foo = 42; sub foo { $foo if 0; sub { $foo } } } print foo->() + 0' 42
On Mon\, Jul 09\, 2007 at 08:55:37PM +0000\, Yitzchak Scott-Thoennes wrote:
This was part of Dave Mitchell's jumbo closure patch that was deemed by him unsafe for 5.8.x. (Dave\, please correct me if I'm wrong.) So expect it in 5.10.0 only.
Correct.
-- "Strange women lying in ponds distributing swords is no basis for a system of government. Supreme executive power derives from a mandate from the masses\, not from some farcical aquatic ceremony." -- Dennis\, "Monty Python and the Holy Grail"
Yitzchak Scott-Thoennes wrote:
Stanislaw Halik \<sthalik \
tehran.lain.pl> writes: Works in 5.9.4. Could you please merge it before the next stable version?
This was part of Dave Mitchell's jumbo closure patch that was deemed by him unsafe for 5.8.x. (Dave\, please correct me if I'm wrong.) So expect it in 5.10.0 only.
s/ unsafe / not backwards compatible / ?!
On Mon\, July 9\, 2007 9:53 pm\, Jim Cromie wrote:
Yitzchak Scott-Thoennes wrote:
This was part of Dave Mitchell's jumbo closure patch that was deemed by him unsafe for 5.8.x. (Dave\, please correct me if I'm wrong.) So expect it in 5.10.0 only.
s/ unsafe / not backwards compatible / ?!
An unclear line\, since by definition any bug fix is not fully backwards compatible.
I would say it's more unsafe than this (also excluded from 5.8.x) bug fix:
$ perl5.9.5 -wle'print $#{@{[0]}}' -1 $ perl5.8.8 -wle'print $#{@{[0]}}' 0
and people seem to be tripping over that a lot.
On Mon\, Jul 09\, 2007 at 10:53:50PM -0600\, Jim Cromie wrote:
This was part of Dave Mitchell's jumbo closure patch that was deemed by him unsafe for 5.8.x. (Dave\, please correct me if I'm wrong.) So expect it in 5.10.0 only.
s/ unsafe / not backwards compatible / ?!
Unsafe in the sense of (a) involving of lot of internal reworking\, so scope for new bugs\, (b) user-visible changes to closure behaviour\, which although "more correct" might well break existing code - hence not really to be slipped into a maint release.
-- "You may not work around any technical limitations in the software" -- Windows Vista license
p5p@spam.wizbit.be - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#43667 (status was 'resolved')
Searchable as RT43667$