Annotated Ada Reference Manual (Ada 202y Draft 1)Legal Information
Contents   Index   References   Search   Previous   Next 

5.2.1 Target Name Symbols

1/5
{AI12-0125-3} @, known as the target name of an assignment statement, provides an abbreviation to avoid repetition of potentially long names in assignment statements. 

Syntax

2/5
{AI12-0125-3} target_name ::= @

Name Resolution Rules

3/5
{AI12-0125-3} [If a target_name occurs in an assignment_statement A, the variable_name V of A is a complete context. The target name is a constant view of V, having the nominal subtype of V.]
3.a/5
Proof: {AI12-0125-3} {AI12-0322-1} The complete context rule is formally given in 8.6. The constant view rule is formally given in 3.3; the nominal subtype is a property taken from the target object as described below in Dynamic Semantics. 

Legality Rules

4/5
{AI12-0125-3} {AI12-0322-1} A target_name shall appear only in the expression of an assignment_statement.

Dynamic Semantics

5/5
{AI12-0125-3} {AI12-0322-1} {AI12-0449-1} For the execution of an assignment_statement with one or more target_names appearing in its expression, the variable_name V of the assignment_statement is evaluated first to determine the object denoted by V, and then the expression of the assignment_statement is evaluated with the evaluation of each target_name yielding a constant view of the target whose properties are otherwise identical to those of the view provided by V. The remainder of the execution of the assignment_statement is as given in 5.2.
5.a/5
To be honest: The properties here include static properties like whether the target_name is aliased and the nominal subtype of the target_name. It was too weird to give separate rules for static and dynamic properties that said almost the same thing. 
5.b/5
Ramification: {AI12-0322-1} Use of a target_name can be erroneous if the variable_name V is a discriminant-dependent component, and some other constituent of the expression modifies the discriminant governing the component V. The assignment probably would be erroneous anyway, but the use of a target_name eliminates the possibility that a later evaluation of V raises an exception before any erroneous execution occurs. See 3.7.2.

Examples

6/5
{AI12-0429-1} Examples of the use of target name symbols:
7/5
{AI12-0125-3} {AI12-0379-1} {AI12-0442-1} Board(1, 1) := @ + 1.0;
            -- An abbreviation for Board(1, 1) := Board(1, 1) + 1.0;
            -- (Board is declared in 3.6.1).
8/5
{AI12-0125-3} My_Complex_Array : array (1 .. Max) of Complex; -- See 3.3.23.8.
...
-- Square the element in the Count (see 3.3.1) position:
My_Complex_Array (Count) := (Re => @.Re**2 - @.Im**2,
                             Im => 2.0 * @.Re * @.Im);
   -- A target_name can be used multiple times and
   -- as a prefix if desired.

Extensions to Ada 2012

8.a/5
{AI12-0125-3} {AI12-0322-1} The target name symbol @ is new. 

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