Operations of Array Types
Author: JTC1/SC22/WG9/ARG, by Randall Brukardt, ARG Editor

Ada Reference Manual — Legal Information

# 3.6.2 Operations of Array Types

#### Legality Rules

1
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

2/1
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:
3
A'First
A'First denotes the lower bound of the first index range; its type is the corresponding index type.
4
A'First(N)
A'First(N) denotes the lower bound of the N-th index range; its type is the corresponding index type.
5
A'Last
A'Last denotes the upper bound of the first index range; its type is the corresponding index type.
6
A'Last(N)
A'Last(N) denotes the upper bound of the N-th index range; its type is the corresponding index type.
7
A'Range
A'Range is equivalent to the range A'First .. A'Last, except that the prefix A is only evaluated once.
8
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.
9
A'Length
A'Length denotes the number of values of the first index range (zero for a null range); its type is universal_integer.
10
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

11/3
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 convention Fortran is specified for a multidimensional array type, then column-major order should be used instead (see B.5, “Interfacing with Fortran”).
NOTES
12
50 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:
13
A'Length(N) = A'Last(N) - A'First(N) + 1
14
51 An array type is limited if its component type is limited (see 7.5).
15
52 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.
16/2
53 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

17
Examples (using arrays declared in the examples of subclause 3.6.1):
18
-- Filter'First = 0 Filter'Last = 31 Filter'Length = 32
-- Rectangle'Last(1) = 20 Rectangle'Last(2) = 30

Ada 2005 and 2012 Editions sponsored in part by Ada-Europe