3.6.2 Operations of Array Types
Legality Rules
[The argument N used in the
attribute_designators
for the N-th dimension of an array shall be a static
expression
of some integer type.] The value of N shall be positive (nonzero) and
no greater than the dimensionality of the array.
Static Semantics
{
8652/0006}
{
AI95-00030-01}
The following attributes are defined for a
prefix
A that is of an array type [(after any implicit dereference)], or denotes
a constrained array subtype:
Ramification: These attributes are not
defined if A is a subtype-mark for an access-to-array subtype. They are
defined (by implicit dereference) for access-to-array values.
A'First
A'First denotes the lower bound
of the first index range; its type is the corresponding index type.
A'First(N)
A'First(N) denotes the lower
bound of the N-th index range; its type is the corresponding index type.
A'Last
A'Last denotes the upper bound
of the first index range; its type is the corresponding index type.
A'Last(N)
A'Last(N) denotes the upper bound
of the N-th index range; its type is the corresponding index type.
A'Range
A'Range is equivalent to the
range A'First .. A'Last, except that the
prefix
A is only evaluated once.
A'Range(N)
A'Range(N) is equivalent to the
range A'First(N) .. A'Last(N), except that the
prefix
A is only evaluated once.
A'Length
A'Length denotes the number of
values of the first index range (zero for a null range); its type is
universal_integer.
A'Length(N)
A'Length(N) denotes the number
of values of the N-th index range (zero for a null range); its type is
universal_integer.
Implementation Advice
An implementation should normally represent multidimensional
arrays in row-major order, consistent with the notation used for multidimensional
array aggregates (see
4.3.3). However, if
a
pragma Convention(Fortran, ...) applies to a multidimensional
array type, then column-major order should be used instead (see
B.5,
“
Interfacing with Fortran”).
Implementation Advice: Multidimensional
arrays should be represented in row-major order, unless the array has
convention Fortran.
47 The
attribute_references
A'First and A'First(1) denote the same value. A similar relation exists
for the
attribute_references
A'Last, A'Range, and A'Length. The following relation is satisfied (except
for a null array) by the above attributes if the index type is an integer
type:
A'Length(N) = A'Last(N) - A'First(N) + 1
48 An array type is limited if its component
type is limited (see
7.5).
49
{predefined
operations (of an array type) [partial]} The
predefined operations of an array type include the membership tests,
qualification, and explicit conversion. If the array type is not limited,
they also include assignment and the predefined equality operators. For
a one-dimensional array type, they include the predefined concatenation
operators (if nonlimited) and, if the component type is discrete, the
predefined relational operators; if the component type is boolean, the
predefined logical operators are also included.
50 {
AI95-00287-01}
A component of an array can be named with an
indexed_component.
A value of an array type can be specified with an
array_aggregate.
For a one-dimensional array type, a slice of the array can be named;
also, string literals are defined if the component type is a character
type.
Examples
Examples (using
arrays declared in the examples of subclause 3.6.1):
-- Filter'First = 0 Filter'Last = 31 Filter'Length = 32
-- Rectangle'Last(1) = 20 Rectangle'Last(2) = 30