This and other RFCs are available on the web at
http://dev.perl.org/rfc/
=head1 TITLE
Array: @#arr for getting the dimensions of an array
=head1 VERSION
Maintainer: Buddha Buck <[EMAIL PROTECTED]>
Date: 8 September 2000
Mailing List: [EMAIL PROTECTED]
Number: 206
Version: 1
Status: Developing
=head1 ABSTRACT
This RFC proposes the use of the @# prefix to get the bounds and
dimensionality of a multidimensional array.
=head1 DESCRIPTION
The $#array notation is useful for getting the upper bound of a
unidimensional array, but is not as useful for getting the upper bounds of
a multidimensional array. A multidimensional array should have a list of
upper bounds, not a single upper bound.
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.
=head2 Example
sub printbounds (\@) {
my $arrayref = shift;
my $array = @$arrayref;
print "D:", scalar @#arrayref," B:(",join(',',@#arrayref),")\n";
}
my int @a :bounds(2,2,2,2,2);
printbounds(@a); # "D:5 B:(2,2,2,2,2)\n"
my int @b :bounds(@a); # create @b the same size as @a
printbounds(@b); # "D:5 B:(2,2,2,2,2)\n"
my @c = (1,2,3,4,5,6,7,8,9,10);
printbounds(@c); # "D:1 B:(9)\n"
=head1 IMPLEMENTATION
Presumably, multidimensional arrays would have to store their bounds
somewhere to have the semantics provided in RFC 203. This operator would
simply return to the user those stored bounds.
Where an array is declared without ':bounds', @# returns the largest
bounds of each dimension that has been accessed:
my int @d = ();
$d[[3,4]] = 5;
@e = @#d; # (3,4)
=head1 REFERENCES
RFC 203: Notation for declaring and creating arrays