On Sun Oct 27 00:22:32 2013, nicholas wrote: > On Sat, Oct 26, 2013 at 01:16:54AM -0700, Father Chrysostomos via RT > wrote: > > 3) Separately store the actual value to be restored on the savestack, > > in addition to the old magical scalar. > > > > #3 is the easiest to implement, and probably the safest in terms of > > backward compatibility. > > Wouldn't that change the behaviour of code which is able to access the > localised variable by another route? eg this code would end up > printing > 5, 6, 5 not what we have currently: > > $ cat /tmp/local.pl > #!/usr/bin/perl -w > use strict; > > $::var = 5; > > print "Before: $::var\n"; > foo (\$::var); > print "After: $::var\n"; > > sub foo { > local $::var; > $::var = 6; > ${$_[0]} = 7; > print "During: $::var\n"; > } > __END__ > $ perl /tmp/local.pl > Before: 5 > During: 6 > After: 7 Yes, it would change that behaviour. Scratch #3 then. You see why nobody wants to fix this? :-) > (I haven't thought very hard about this, but the whole thing does seem > to be > a tricky problem. I'm not sure if the underlying mess is that for > magic > variables that proxy through to some other storage, Perl's local isn't > localising that underlying storage) I think that is the underlying problem. But how do you fix that for ties? I.e., how do we make your example work with Tie::StdScalar? Do we need to introduce LOCAL and UNWIND methods for ties? Currently with $::var tied to Tie::StdScalar, it prints: Before: 5 During: 7 After: 7 And with $! it prints the same, if you print 0+$!. -- Father Chrysostomos --- via perlbug: queue: perl5 status: open https://rt.perl.org/Ticket/Display.html?id=119683Thread Previous