Rob Kinyon wrote:

So, does this mean that I can do something like:

 @a = [ 1 .. 4 ];
 $x = @a{2};

and have $x == 3? If so, is there any reason (other than clarity) to
use the @a[] notation? The @ already indicates you have an array vs.
the % which indicates hash. Is there a reason to have the subscripting
notation also be different?


There are optimizations to be had if the compiler knows you're using numerics.

If I understand things, Arrays are just really optimized hashes, with a few constraints on the keys.

I understand why it was different in P5, given that you needed to
differentiate $x->[2] and $x->{2} and allow the reader to know whether
$x was an arrayref or hashref. But, that need is gone from P6. (Isn't
it?)



As long as you're calling your arrays @x. There's still the distinct and likely possibility of storing your array in $x, in which case it's not at all obvious that $x{2} is calling an array.


-- Rod Adams



Reply via email to