On Mon, Aug 18, 2008 at 01:38:05PM -0500, 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? I would somewhat expect : a reference to be instead handled using a statement like : : $foo[1] := $bar; : : Comments and clarifications appreciated.
Well, sure, you can use := for clarity, but we left = in the language to provide (to the extent possible) the same semantics that it does in Perl 5. And when it comes to non-value types, there really are still references, even if we try not to talk about them much. So I think assignment is basically about copying around identities, where value types treat identity differently than object types (or at least, objects types that aren't pretending to be value types). In any case, an array or a hash is not pretending to be a value type, so it just clones its identity (a reference, if you will) by default. It's quite possible this is insane, but I can't tell in my current state of jet lag. Larry