Larry Wall wrote:
On Sat, Jan 08, 2005 at 11:37:06AM -0700, Craig DeForest wrote:

: Is the perl6 expression
:       @a[4; 0..5];
: a 1x6 array (probably correct)?  Or a 6 array (probably not correct)?

Certainly the former.  I don't think dimensions should ever disappear
accidentally.

Except when you assign in scalar context -- which I guess isn't accidental.

We know that

@a = (1, 2, 3);
$b = @a[1];

Loses the dimension as a DWIM.

So perhaps we could say that assigning to a lower dimension always gets rid of a dimension of size 1 -- or error if it can't:

@c = ( 1,2,3 ; 4,5,6 );
@d[*;*] = @c[ 1 ; * ]; # @d is 2d
@e[*] = @c[ 1 ; * ];  # @e is 1d
@f = @c[1;1];      # @f is 2d: no dimensions lost

@g[*] = @c[ 0,1 ; 0,1 ]; # error: cannot collapse

as our disambiguator.

{ @c[;*] but shape(*) } wouldn't work, because the :shape option leaves additional dimensions open.


Dave.

Reply via email to