4.1.1 Indexed Components
1
[An
indexed_component
denotes either a component of an array or an entry in a family of entries.
]
Syntax
2
Name Resolution Rules
3
The
prefix
of an
indexed_component
with a given number of
expressions
shall resolve to denote an array (after any implicit dereference) with
the corresponding number of index positions, or shall resolve to denote
an entry family of a task or protected object (in which case there shall
be only one
expression).
4
The expected type for each
expression
is the corresponding index type.
Static Semantics
5
When the
prefix
denotes an array, the
indexed_component
denotes the component of the array with the specified index value(s).
The nominal subtype of the
indexed_component
is the component subtype of the array type.
5.a/2
Ramification: {
AI95-00363-01}
In the case of an array whose components are aliased,
and of an unconstrained discriminated subtype, the components are constrained
even though their nominal subtype is unconstrained. (This is because
all aliased discriminated objects are constrained. See 3.10.2.)
In all other cases, an array component is constrained if and only if
its nominal subtype is constrained.
6
When the
prefix
denotes an entry family, the
indexed_component
denotes the individual entry of the entry family with the specified index
value.
Dynamic Semantics
7
For the evaluation of an
indexed_component,
the
prefix
and the
expressions
are evaluated in an arbitrary order.
The value of
each
expression
is converted to the corresponding index type.
A
check is made that each index value belongs to the corresponding index
range of the array or entry family denoted by the
prefix.
Constraint_Error is raised if this check fails.
Examples
8
Examples of indexed
components:
9
My_Schedule(Sat) --
a component of a one-dimensional array (see 3.6.1)
Page(10) --
a component of a one-dimensional array (see 3.6)
Board(M, J + 1) --
a component of a two-dimensional array (see 3.6.1)
Page(10)(20) --
a component of a component (see 3.6)
Request(Medium) --
an entry in a family of entries (see 9.1)
Next_Frame(L)(M, N) --
a component of a function call (see 6.1)
10
1 Notes on the examples: Distinct
notations are used for components of multidimensional arrays (such as
Board) and arrays of arrays (such as Page). The components of an array
of arrays are arrays and can therefore be indexed. Thus Page(10)(20)
denotes the 20th component of Page(10). In the last example Next_Frame(L)
is a function call returning an access value that designates a two-dimensional
array.
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe