I just re-read Synopsis 9, which covers PDL-related actions and array slicing, 
and came to the conclusion that either (A) there's a hole in the syntax as it 
is lain out,  (B) I lack sufficient understanding of what has been thought 
out so far, or (C) that part of the language definition isn't finished yet.

Is the perl6 expression
        @a[4; 0..5];
a 1x6 array (probably correct)?  Or a 6 array (probably not correct)? If the
former, how do you specify that you want the latter?  There's a significant 
difference between the two -- for example, if '4' is some list expression 
that happens to have just one element, you don't want the whole shape of the 
output array to change.

The problem is the near-universal wart that scalars are not merely lists with 
but a single element, so you need to be able to tell the difference between a 
dimension that exists but has size 1, and a dimension that doesn't exist.
(In perl5, all arrays are one-dimensional, so the issue is sidestepped by the 
presence of scalar/list context.)

Perl5/PDL solves the problem with 'extra-parenthesis' syntax in slicing, and 
with zero-size dimensions in operators like range() [no relation to perl6 
range operators] that take a dimension size list.  Examples:
        $a(  4,  0:5 );          # This perl5/PDL slice is a 1x6-array
        $a( (4), 0:5 );          # This perl5/PDL slice is a 6-array
        $a->range($xy,[1,3]);    # This perl5/PDL range is a 1x3-array
        $a->range($xy,[0,3]);    # This perl5/PDL range is a 3-array
The extra parens only remove the dimension if they would otherwise be no-ops.

It is not (yet) clear to me whether the extra parens syntax is a good solution 
for perl 6 slices.

Reply via email to