4.1.3 Selected Components
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
Name Resolution Rules
A 
selected_component 
that is not an expanded name shall resolve to denote one of the following: 
 
A component (including a discriminant):
A single entry, an entry family, or a protected 
subprogram:
A view of a subprogram whose first formal parameter 
is of a tagged type or is an access parameter whose designated type is 
tagged:
The 
prefix 
(after any implicit dereference) shall resolve to denote an object or 
value of a specific tagged type 
T or class-wide type 
T'Class. 
The 
selector_name 
shall resolve to denote a view of a subprogram declared immediately within 
the declarative region in which an ancestor of the type 
T is declared. 
The first formal parameter of the subprogram shall be of type 
T, 
or a class-wide type that covers 
T, or an access parameter designating 
one of these types. The designator of the subprogram shall not be the 
same as that of a component of the tagged type visible at the point of 
the 
selected_component. 
The subprogram shall not be an implicitly declared primitive operation 
of type 
T that overrides an inherited subprogram implemented by 
an entry or protected subprogram visible at the point of the 
selected_component. 
The 
selected_component 
denotes a view of this subprogram that omits the first formal parameter. 
This view is called a 
prefixed view of the subprogram, and the 
prefix of 
the 
selected_component 
(after any implicit dereference) is called the 
prefix of the prefixed 
view. 
 
An expanded name shall 
resolve to denote a declaration that occurs immediately within a named 
declarative region, as follows: 
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.
 
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 
8.3). 
The expanded name denotes that declaration. 
 
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.
 
Legality Rules
   For a subprogram whose first parameter is an access 
parameter, the prefix of any prefixed view shall denote an aliased view 
of an object.
   For a subprogram whose first parameter is of mode 
in out or out, or of an anonymous access-to-variable type, 
the prefix of any prefixed view shall denote a variable.
Dynamic Semantics
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
Examples of selected 
components: 
  Tomorrow.Month     --
  a record component                      (see 3.8)
  Next_Car.Owner     --
  a record component                      (see 3.10.1)
  Next_Car.Owner.Age --
  a record component                      (see 3.10.1)
                     --
  the previous two lines involve implicit dereferences
  Writer.Unit        --
  a record component (a discriminant)     (see 3.8.1)
  Min_Cell(H).Value  --
  a record component of the result        (see 6.1)
                     --
  of the function call Min_Cell(H)
  Cashier.Append     --
  a prefixed view of a procedure          (see 3.9.4)
  Control.Seize      --
  an entry of a protected object          (see 9.4)
  Pool(K).Write      --
  an entry of the task Pool(K)            (see 9.4) 
Examples of expanded 
names: 
  Key_Manager."<"      --
  an operator of the visible part of a package  (see 7.3.1)
  Dot_Product.Sum      --
  a variable declared in a function body       (see 6.1)
  Buffer.Pool          --
  a variable declared in a protected unit      (see 9.11)
  Buffer.Read          --
  an entry of a protected unit                 (see 9.11)
  Swap.Temp            --
  a variable declared in a block statement     (see 5.6)
  Standard.Boolean     --
  the name of a predefined type                (see A.1) 
Ada 2005 and 2012 Editions sponsored in part by Ada-Europe