Will Coleda wrote: > On Sun, Jun 22, 2008 at 2:59 PM, Frederik Schwarzer > <[EMAIL PROTECTED]> wrote: >> Hi, >> >> there is something I do not understand. >> I reduced the code to a minimal case. >> >> If I do: >> my $a = 23; >> my $b = $a; # copy >> $a = 42; >> say $b; # 23 >> $b is 23, >> and if I do: >> my $a = 23; >> my $b := $a; # reference >> $a = 42; >> say $b; # 42 >> $b is 42 because it is just a reference to $a. >> >> But if I do: >> my @arr = (23, 42); >> my $temp = @arr[0]; # copy? >> @arr[0] = @arr[1]; >> say $temp; # 42 >> $temp is 42 ... >> I expected $temp to be 23 here. >> >> Am I missing something? >> >> Regards, >> Frederik >> > > Which implementation of Perl 6 are you using here? In Rakudo, > everything works as you describe except for the last example which > dies on the last line with: > > Scope not found for PAST::Var '$temp' > current instr.: 'parrot;PCT::HLLCompiler;panic' pc 156 > (src/PCT/HLLCompiler.pir:103)
Did you use the interactive (REPL) rakudo prompt? If so, no wonder - it currently puts an implicit block around each line. In the non-interactive version it wroks as Frederik described, which is certainly a bug: $ cat test.t my @arr = (23, 42); my $temp = @arr[0]; # copy? @arr[0] = @arr[1]; say $temp; # 42 $ ../../parrot perl6.pbc test.t 42 Part of the problem is that it's not really tested because t/spec/S03-operators/assign.t can't be parsed by rakudo correctly, and the fudged version 1) exhibits GC bugs and 2) is mis-parsed by fudge and reports the number of tests wrongly. I'll probably move some of the simpler tests to a separate file to work around these limitations for now (currently assign.t has 308 tests, which is way above average anyway) Cheers, Moritz -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/