* Damian Conway <[EMAIL PROTECTED]> [05/11/2001 14:46]:
>
> Here's a translation table from my soon-to-be-released article, Exegesis 2:
>
> Access through... Perl 5 Perl 6
> ================= ====== ======
> Array slice @foo[$n] <TBA>
> Hash slice @foo{$k} <TBA>
Looks good. Actually, though, I don't see any reason why these notations
shouldn't be unified. That is:
$b = @a[0]; # $b gets @a's 1st element
$c = @a[1,2]; # $c gets @a's 2nd element
($c) = @a[1,2]; # $c gets @a's 1st element
($d, $e) = @a[3,4]; # $d = @a[3], $e = @a[4]
$f = %h{k}; # $f gets %h's "k" value
$g = %h{'k1','k2'} # $g = %h{k2}
($g) = %h{'k1','k2'} # $g = %h{k1}
($h, $i) = %h{'k1','k2'} # $h = %h{k1}, $i = %h{k2}
The argument goes like this: @ no longer really indicates context, but
type, since you can say (@a, @b) = (@c, @d) w/o flattening. As such, the
context is really dependent on the () casting on the LHS and the
elements referenced on the RHS.
The above semantics I'm suggesting are actually consistent with Perl 5
right now:
$ perl
$d = (1, 2, 3);
print "d = $d\n";
($e) = (4, 5, 6);
print "e = $e\n";
^D
d = 3
e = 4
The notation is just extending the "$@% means type" idea to slices as
well.
-Nate