Patrick R. Michaud wrote: > There are quite a few tests in the spectest suite that > make mention of "arrayref" and "hashref", and that expect > things to work like references do in Perl 5. I'd like to > get some confirmation/clarification on them. > > Here's one example: > > my $foo = [ 42 ]; > my $bar = { a => 23 }; > $foo[1] = $bar; > $bar<b> = 24; > > say $foo[1]<b>; # "24" or undef ??? > > The test suite expects "24" to be output here, treating > treating C< $foo[1] > as a reference to the hash in > C<$bar>, such that any changes to C<$bar> are also reflected > in C<$foo[1]>. Is this correct Perl 6?
IMHO yes. Remember that $foo is really just an Array object, just like any other object. Why should Array objects be cloned on assignment? If you do a @a = @b you get cloning behaviour because the @ sigil implies a container type, whereas a with a $ sigil you just hand references to objects. > I would somewhat expect > a reference to be instead handled using a statement like > > $foo[1] := $bar; > > Comments and clarifications appreciated. > > Pm -- Moritz Lenz http://moritz.faui2k3.org/ | http://perl-6.de/