--- Jonadab the Unsightly One <[EMAIL PROTECTED]> wrote: > "Jonadab the Unsightly One" <[EMAIL PROTECTED]> writes: > > > Does this imply, though, that it's pointing to specific elements, > > Wow, I wasn't paying attention to what I was thinking there. > Obviously it points to specific elements, because the subscripts used > to create a slice don't have to be sequential or even in order. I > (theoretically) knew that... > > > print @a; # 0 1 2 3 4 5 > > print @$r_slice; # 0 1 2 3 > > splice @a, 2, 0, 6; # 0 1 6 2 3 4 5 > print @$r_slice; # 0 1 2 3 > splice @a, 1, 1, 7; # 0 7 6 2 3 4 5 > print @$r_slice; # 0 7 2 3 > > Am I now thinking clearly? > I don't think so.
If you've created two separate arrays that happen to start with related values, then the changes to the first won't affect the second. If splice overwrites the values instead of dropping and then replacing them, it's going to produce some strange behavior. I think that for example: my @a is Array of int; my $r_slice is Array of int; # ... as before ... should behave as expected, and "expected" in this case means copy-on-assign. OTOH, if you said C<$r_slice := @a ...> then you'd be binding, not copying, and the one-change-affects-both behavior is in effect. =Austin