Re: RFC 206 (v1) Array: @#arr for getting the dimensions of an array
[email protected] ("Jeremy Howard") Sat, 9 Sep 2000 18:04:31 +1100
| Newsgroups | perl.perl6.language.data |
|---|---|
| Message-ID | <[email protected]> |
[email protected] wrote: > Perl6 RFC Librarian wrote: > > > This RFC proposes using @#array, analogous to $#array, to get the list of > > upper bounds for a multidimensional array @array. The length of @#array > > would indicate the dimensionality of @array. > > That's fine. This RFC does not seem to touch on the question what > $#array should be for a multidim array (e.g., $#array == $#{flatten @a} > or rather undef). Or is that dealt with in another RFC? > It's dealt with in RFC 203 'Arrays: Notation for declaring and creating arrays': <quote> These arrays support I<all> the same syntax as lists. Therefore any description of syntax for a 'list' also applies to an 'array', and visa versa </quote> Therefore: my int @a = ([1,2], [3,4]); $#a == 1; # As it does in Perl 5 (for untyped lists) my @b :bounds(2,2); $#b == 2; # Because @b== ([undef,undef,undef], # [undef,undef,undef], # [undef,undef,undef])