next up previous contents
Next: Blocks and Exception Handling Up: Statements Previous: Statements

Assignments

 
  assignment ::= designator ':=' general_expression .

Example: var := op1 * op2; arr[4] := 5; obj.attr := 7 tex2html_wrap_inline1707

Certain assignments are transformed into procedure calls before processing, cf. 4.5.

Any other assignment is processed by simultaneously evaluating the designator and the general expression. Then the entity identified by the designator is made to denote a copy of the value of the general expression.

The designator must evaluate to a non-constant attribute of the class in which the assignment occurs, a local variable, a shared attribute qualified by a class or an attribute qualified by an object; such attributes of other classes or objects must not be private, constant or readonly. Assignments to self are not allowed but self may occur as the qualifier of an designator. (For self see 6.7.)

In general, the type of the general expression must conform to the type of the designator. In case of value types it is also allowed that the type of the expression is coercible to the type of the designator, cf. 7.2.

Hint: Simultaneous evaluation of several expressions means: The evaluation of the expressions may be arbitrarily merged in time or may even be done in parallel; hence side-effects from evaluating one of the expression may lead to unpredictable results. tex2html_wrap_inline1707



Martin Trapp
Mon Feb 17 16:49:16 MET 1997