Ada Reference Manual (Ada 2022)Legal Information
Contents   Index   References   Search   Previous   Next 

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
indexed_component ::= prefix(expression {, expression})

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. 
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/5
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.

Contents   Index   References   Search   Previous   Next 
Ada-Europe Ada 2005 and 2012 Editions sponsored in part by Ada-Europe