Annotated Ada Reference ManualLegal Information
Contents   Index   References   Search   Previous   Next 

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
{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: 
2.a
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.
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
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”). 
11.a/2
Implementation Advice: Multidimensional arrays should be represented in row-major order, unless the array has convention Fortran.
NOTES
12
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: 
13
   A'Length(N) = A'Last(N) - A'First(N) + 1
14
48  An array type is limited if its component type is limited (see 7.5).
15
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.
16/2
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

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

Contents   Index   References   Search   Previous   Next 
Ada-Europe Sponsored by Ada-Europe