Go to the first, previous, next, last section, table of contents.


4.1.3 Selected Components

  1. Selected_components are used to denote components (including discriminants), entries, entry families, and protected subprograms; they are also used as expanded names as described below.

    Syntax

  2. selected_component ::= prefix . selector_name
    
  3. selector_name ::= identifier | character_literal | operator_symbol
    

    Name Resolution Rules

  4. A selected_component is called an expanded name if, according to the visibility rules, at least one possible interpretation of its prefix denotes a package or an enclosing named construct (directly, not through a subprogram_renaming_declaration or generic_renaming_declaration).
  5. A selected_component that is not an expanded name shall resolve to denote one of the following:
    1. A component (including a discriminant):
      1. The prefix shall resolve to denote an object or value of some non-array composite type (after any implicit dereference). The selector_name shall resolve to denote a discriminant_specification of the type, or, unless the type is a protected type, a component_declaration of the type. The selected_component denotes the corresponding component of the object or value.

    1. A single entry, an entry family, or a protected subprogram:
      1. The prefix shall resolve to denote an object or value of some task or protected type (after any implicit dereference). The selector_name shall resolve to denote an entry_declaration or subprogram_declaration occurring (implicitly or explicitly) within the visible part of that type. The selected_component denotes the corresponding entry, entry family, or protected subprogram.

  1. An expanded name shall resolve to denote a declaration that occurs immediately within a named declarative region, as follows:
    1. The prefix shall resolve to denote either a package (including the current instance of a generic package, or a rename of a package), or an enclosing named construct.
    2. The selector_name shall resolve to denote a declaration that occurs immediately within the declarative region of the package or enclosing construct (the declaration shall be visible at the place of the expanded name -- See section 8.3 Visibility.). The expanded name denotes that declaration.
    3. If the prefix does not denote a package, then it shall be a direct_name or an expanded name, and it shall resolve to denote a program unit (other than a package), the current instance of a type, a block_statement, a loop_statement, or an accept_statement (in the case of an accept_statement or entry_body, no family index is allowed); the expanded name shall occur within the declarative region of this construct. Further, if this construct is a callable construct and the prefix denotes more than one such enclosing callable construct, then the expanded name is ambiguous, independently of the selector_name.

Dynamic Semantics

  1. The evaluation of a selected_component includes the evaluation of the prefix.
  2. For a selected_component that denotes a component of a variant, a check is made that the values of the discriminants are such that the value or object denoted by the prefix has this component. The exception Constraint_Error is raised if this check fails.

    Examples

  3. Examples of selected components:
  4. Tomorrow.Month
    --  a record component                   See section 3.8 Record Types
    
    Next_Car.Owner
    --  a record component                   See section 3.10.1 Incomplete Type Declarations
    
    Next_Car.Owner.Age
    --  a record component                   See section 3.10.1 Incomplete Type Declarations
    --  the previous two lines involve implicit dereferences
    
    Writer.Unit
    --  a record component (a discriminant)  See section 3.8.1 Variant Parts and Discrete Choices
    
    Min_Cell(H).Value
    --  a record component of the result     See section 6.1 Subprogram Declarations
    --  of the function call Min_Cell(H)
    
    Control.Seize
    --  an entry of a protected object       See section 9.4 Protected Units and Protected Objects
    
    Pool(K).Write
    --  an entry of the task Pool(K)         See section 9.4 Protected Units and Protected Objects
    
  5. Examples of expanded names:
  6. Key_Manager."<"
    --  an operator of the visible part of a package  See section 7.3.1 Private Operations
    
    Dot_Product.Sum
    --  a variable declared in a function body        See section 6.1 Subprogram Declarations
    
    Buffer.Pool
    --  a variable declared in a protected unit       See section 9.11 Example of Tasking and Synchronization
    
    Buffer.Read
    --  an entry of a protected unit                  See section 9.11 Example of Tasking and Synchronization
    
    Swap.Temp
    --  a variable declared in a block statement      See section 5.6 Block Statements
    
    Standard.Boolean
    --  the name of a predefined type                 See section A.1 The Package Standard
    


Go to the first, previous, next, last section, table of contents.