On Sat, Dec 04, 2004 at 06:01:45AM +0300, Alexey Trofimenko wrote: : : my $var="foo"; : { : temp $var; : say $var; : } : : would it be undef or "foo"?
It's undef if we follow Perl 5. (Early Perls actually kept the original value, but that was deemed improper at some point.) : if the former, how could I make $var to : contain a copy of original content? : using analogy with my $x = $x, that's not going to work.. : : temp $var = $OUTER::var? That's presumably correct if we take "my" as the prototype. Though temp is just an operator, not a declarator, and depending on order of evaluation it's possible that temp $var = $var might do the right thing. Then again, it might not. : OTOH, : : my @a = ... # something not lazy with 10_000_000 elements.. : { : temp @a; # ouch! temporal clone! : } : : that could hurt.. Perl 5 actually localizes a binding when you do that rather than copying. Perl 6 can presumably distinguish binding from copying, so we probably need to encourage people to bind temporarily rather than assigning. And bare temp @a; would be taken as equivalent to temp @a := (); Larry