4.1. Names

[UP][NEXT]

Names can denote declared entities, whether declared explicitly or implicitly (see 3.1). Names can also denote objects designated by access values; subcomponents and slices of objects and values; single entries, entry families, and entries in families of entries. Finally, names can denote attributes of any of the foregoing.

    name ::= simple_name
       | character_literal  | operator_symbol
       | indexed_component  | slice
       | selected_component | attribute 

    simple_name ::= identifier 

    prefix ::= name | function_call 

A simple name for an entity is either the identifier associated with the entity by its declaration, or another identifier associated with the entity by a renaming declaration.

Certain forms of name (indexed and selected components, slices, and attributes) include a prefix that is either a name or a function call. If the type of a prefix is an access type, then the prefix must not be a name that denotes a formal parameter of mode out or a subcomponent thereof.

If the prefix of a name is a function call, then the name denotes a component, a slice, an attribute, an entry, or an entry family, either of the result of the function call, or (if the result is an access value) of the object designated by the result.

A prefix is said to be appropriate for a type in either of the following cases:

The evaluation of a name determines the entity denoted by the name. This evaluation has no other effect for a name that is a simple name, a character literal, or an operator symbol.

The evaluation of a name that has a prefix includes the evaluation of the prefix, that is, of the corresponding name or function call. If the type of the prefix is an access type, the evaluation of the prefix includes the determination of the object designated by the corresponding access value; the exception CONSTRAINT_ERROR is raised if the value of the prefix is a null access value, except in the case of the prefix of a representation attribute (see 13.7.2).

Examples of simple names:

    PI      --  the simple name of a number               (see 3.2.2)
    LIMIT   --  the simple name of a constant             (see 3.2.1)
    COUNT   --  the simple name of a scalar variable      (see 3.2.1)
    BOARD   --  the simple name of an array variable      (see 3.6.1)
    MATRIX  --  the simple name of a type                 (see 3.6)
    RANDOM  --  the simple name of a function             (see 6.1)
    ERROR   --  the simple name of an exception           (see 11.1) 

References: access type, access value, attribute, belong to a type, character literal, component, constraint_error exception, declaration, designate, designated type, entity, entry, entry family, evaluation, formal parameter, function call, identifier, indexed component, mode, null access value, object, operator symbol, raising of exceptions, renaming declarations, selected component, slice, subcomponent, type.

Sub-topics:

4.1.1. Indexed Components

[UP][NEXT]

An indexed component denotes either a component of an array or an entry in a family of entries.

    indexed_component ::= prefix(expression {, expression}) 

In the case of a component of an array, the prefix must be appropriate for an array type. The expressions specify the index values for the component; there must be one such expression for each index position of the array type. In the case of an entry in a family of entries, the prefix must be a name that denotes an entry family of a task object, and the expression (there must be exactly one) specifies the index value for the individual entry.

Each expression must be of the type of the corresponding index. For the evaluation of an indexed component, the prefix and the expressions are evaluated in some order that is not defined by the language. The exception CONSTRAINT_ERROR is raised if an index value does not belong to the range of the corresponding index of the prefixing array or entry family.

Examples of indexed components:

 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.5)
 NEXT_FRAME(L)(M, N)  --  a component of a function call          (see 6.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 which designates a two-dimensional array.

References: appropriate for a type, array type, component, component of an array, constraint_error exception, dimension, entry, entry family, evaluation, expression, function call, in some order, index, name, prefix, raising of exceptions, returned value, and 6.5, task object.

4.1.2. Slices

[PREVIOUS][UP][NEXT]

A slice denotes a one-dimensional array formed by a sequence of consecutive components of a one-dimensional array. A slice of a variable is a variable; a slice of a constant is a constant; a slice of a value is a value.

    slice ::= prefix(discrete_range) 

The prefix of a slice must be appropriate for a one-dimensional array type. The type of the slice is the base type of this array type. The bounds of the discrete range define those of the slice and must be of the type of the index; the slice is a null slice denoting a null array if the discrete range is a null range.

For the evaluation of a name that is a slice, the prefix and the discrete range are evaluated in some order that is not defined by the language. The exception CONSTRAINT_ERROR is raised by the evaluation of a slice, other than a null slice, if any of the bounds of the discrete range does not belong to the index range of the prefixing array. (The bounds of a null slice need not belong to the subtype of the index.)

Examples of slices:

  STARS(1 .. 15)        --  a slice of 15 characters       (see 3.6.3)
  PAGE(10 .. 10 + SIZE) --  a slice of 1 + SIZE components (see 3.6 and 3.2.1)
  PAGE(L)(A .. B)       --  a slice of the array PAGE(L)   (see 3.6)
  STARS(1 .. 0)         --  a null slice                   (see 3.6.3)
  MY_SCHEDULE(WEEKDAY)  --  bounds given by subtype        (see 3.6 and 3.5.1)
  STARS(5 .. 15)(K)     --  same as STARS(K)               (see 3.6.3)
                        --  provided that K is in 5 .. 15

Notes:

For a one-dimensional array A, the name A(N .. N) is a slice of one component; its type is the base type of A. On the other hand, A(N) is a component of the array A and has the corresponding component type.

References: appropriate for a type, array, array type, array value, base type, belong to a subtype, bound of a discrete range, component, component type, constant, constraint, constraint_error exception, dimension, discrete range, evaluation, index, index range, name, null array, null range, prefix, raising of exceptions, type, variable.

4.1.3. Selected Components

[PREVIOUS][UP][NEXT]

Selected components are used to denote record components, entries, entry families, and objects designated by access values; they are also used as expanded names as described below.

    selected_component ::= prefix.selector 

    selector ::= simple_name
       | character_literal | operator_symbol | all                                                     

The following four forms of selected components are used to denote a discriminant, a record component, an entry, or an object designated by an access value:

  1. A discriminant:

    The selector must be a simple name denoting a discriminant of an object or value. The prefix must be appropriate for the type of this object or value.

  2. A component of a record:

    The selector must be a simple name denoting a component of a record object or value. The prefix must be appropriate for the type of this object or value.

    For a component of a variant, a check is made that the values of the discriminants are such that the record has this component. The exception CONSTRAINT_ERROR is raised if this check fails.

  3. A single entry or an entry family of a task:

    The selector must be a simple name denoting a single entry or an entry family of a task. The prefix must be appropriate for the type of this task.

  4. An object designated by an access value:

    The selector must be the reserved word all. The value of the prefix must belong to an access type.

A selected component of one of the remaining two forms is called an expanded name. In each case the selector must be either a simple name, a character literal, or an operator symbol. A function call is not allowed as the prefix of an expanded name. An expanded name can denote:

  1. An entity declared in the visible part of a package:

    The prefix must denote the package. The selector must be the simple name, character literal, or operator symbol of the entity.

  2. An entity whose declaration occurs immediately within a named construct:

    The prefix must denote a construct that is either a program unit, a block statement, a loop statement, or an accept statement. In the case of an accept statement, the prefix must be either the simple name of the entry or entry family, or an expanded name ending with such a simple name (that is, no index is allowed). The selector must be the simple name, character literal, or operator symbol of an entity whose declaration occurs immediately within the construct.

    This form of expanded name is only allowed within the construct itself (including the body and any subunits, in the case of a program unit). A name declared by a renaming declaration is not allowed as the prefix. If the prefix is the name of a subprogram or accept statement and if there is more than one visible enclosing subprogram or accept statement of this name, the expanded name is ambiguous, independently of the selector.

If, according to the visibility rules, there is at least one possible interpretation of the prefix of a selected component as the name of an enclosing subprogram or accept statement, then the only interpretations considered are those of rule (f), as expanded names (no interpretations of the prefix as a function call are then considered).

The evaluation of a name that is a selected component includes the evaluation of the prefix.

Examples of selected components:

  TOMORROW.MONTH     --  a record component                    (see 3.7)
  NEXT_CAR.OWNER     --  a record component                    (see 3.8.1)
  NEXT_CAR.OWNER.AGE --  a record component                    (see 3.8.1)
  WRITER.UNIT        --  a record component (a discriminant)   (see 3.7.3)
  MIN_CELL(H).VALUE  --  a record component of the result  (see 6.1 and 3.8.1)
                     --  of the function call MIN_CELL(H)
  CONTROL.SEIZE      --  an entry of the task CONTROL      (see 9.1 and 9.2)
  POOL(K).WRITE      --  an entry of the task POOL(K)      (see 9.1 and 9.2)

  NEXT_CAR.all       --  the object designated by
                     --  the access variable NEXT_CAR       (see 3.8.1)

Examples of expanded names:

  TABLE_MANAGER.INSERT --  a procedure of the visible part of a package
                           (see 7.5)
  KEY_MANAGER."<"      --  an operator of the visible part of a package
                           (see 7.4.2)
  DOT_PRODUCT.SUM      --  a variable declared in a procedure body (see 6.5)
  BUFFER.POOL          --  a variable declared in a task unit (see 9.12)
  BUFFER.READ          --  an entry of a task unit (see 9.12)
  SWAP.TEMP            --  a variable declared in a block statement (see 5.6)
  STANDARD.BOOLEAN     --  the name of a predefined type (see 8.6 and C)

Note:

For a record with components that are other records, the above rules imply that the simple name must be given at each level for the name of a subcomponent. For example, the name NEXT_CAR.OWNER.BIRTH.MONTH cannot be shortened (NEXT_CAR.OWNER.MONTH is not allowed).

References: accept statement, access type, access value, appropriate for a type, block statement, body of a program unit, character literal, component of a record, constraint_error exception, declaration, designate, discriminant, entity, entry, entry family, function call, index, loop statement, object, occur immediately within, operator, type, prefix, procedure body, program unit, raising of exceptions, record, record component, renaming declaration, reserved word, simple name, subprogram, subunit, task, task object, task unit, variable, variant, visibility, visible part.

4.1.4. Attributes

[PREVIOUS][UP]

An attribute denotes a basic operation of an entity given by a prefix.

    attribute ::= prefix'attribute_designator 

    attribute_designator ::= simple_name [(universal_static_expression)] 

The applicable attribute designators depend on the prefix. An attribute can be a basic operation delivering a value; alternatively it can be a function, a type, or a range. The meaning of the prefix of an attribute must be determinable independently of the attribute designator and independently of the fact that it is the prefix of an attribute.

The attributes defined by the language are summarized in Annex A. In addition, an implementation may provide implementation-defined attributes; their description must be given in Appendix F. The attribute designator of any implementation-defined attribute must not be the same as that of any language-defined attribute.

The evaluation of a name that is an attribute consists of the evaluation of the prefix.

Notes:

The attribute designators DIGITS, DELTA, and RANGE have the same identifier as a reserved word. However, no confusion is possible since an attribute designator is always preceded by an apostrophe. The only predefined attribute designators that have a universal expression are those for certain operations of array types (see 3.6.2).

Examples of attributes:

  COLOR'FIRST        -- minimum value of the enumeration type COLOR
                        (see 3.3.1 and 3.5)
  RAINBOW'BASE'FIRST -- same as COLOR'FIRST (see 3.3.2 and 3.3.3)
  REAL'DIGITS        -- precision of the type REAL (see 3.5.7 and 3.5.8)
  BOARD'LAST(2)      -- upper bound of the second dimension of BOARD
                        (see 3.6.1 and 3.6.2)
  BOARD'RANGE(1)     -- index range of the first dimension of BOARD
                        (see 3.6.1 and 3.6.2)
  POOL(K)'TERMINATED -- TRUE if task POOL(K) is terminated (see 9.2 and 9.9)
  DATE'SIZE          -- number of bits for records of type DATE
                        (see 3.7   and 13.7.2)
  MESSAGE'ADDRESS    -- address of the record variable MESSAGE
                        (see 3.7.2 and 13.7.2)

References: appropriate for a type, basic operation, declared entity, name, prefix, reserved word, simple name, static expression, type, universal expression.


[INDEX][CONTENTS]