Lugaru's Epsilon
Programmer's
Editor 14.04

Context:
Epsilon User's Manual and Reference
   Epsilon Extension Language
      . . .
      Order of Evaluation
      Expressions
         . . .
         Unary Operators
         Simple Binary Operators
         Assignment Operators
         Function Calls
         Miscellaneous Operators
      Constant Expressions
      . . .

Previous   Up    Next
Simple Binary Operators  Epsilon Extension Language   Function Calls


Epsilon User's Manual and Reference > Epsilon Extension Language > Expressions >

Assignment Operators

expression:
        expression = expression
        expression modify-operator expression

modify-operator:
        +=
        -=
        *=
        /=
        %=
        &=
        |=
        ^=
        <<=
        >>=

The plain assignment operator = takes an lvalue (see Constants and Identifiers) as its first operand. The object referred to by the lvalue is given the value of the second operand. The types of the operands may both be numbers, spots, pointers to the same type of object, or compatible structures. If the first operand is a pointer or spot and the second is the constant zero, the pointer or spot is made null. The value of the expression is the new value of the first operand, and it has the same type.

The other kinds of assignment operators are often used simply as abbreviations. For example, if a is a variable, a += (b) is the same as a = a + (b). However, the first operand of an assignment is only evaluated once, so if it has side effects, they will only occur once.

For example, suppose a is an array of integers with values 10, 20, 30, and so forth. Suppose p() is a function that will return a pointer to the first element of a the first time it's called, then a pointer to the second element, and so forth. After the statement *p() += 3;, a will contain 13, 20, 30. After *p() = *p() + 3;, however, a is certain not to contain 13, 20, 30, since p() will never return a pointer to the same element of a twice. Because the order of evaluation is unspecified with these operators, the exact result of the latter statement is undefined (either 10, 13, 30 or 23, 20, 30).

The result of all these assignment statements is the new value of the first operand, and will have the same type. The special rules for mixing pointers and ints with the + and - operators also apply here.



Previous   Up    Next
Simple Binary Operators  Epsilon Extension Language   Function Calls


Lugaru Epsilon Programmer's Editor 14.04 manual. Copyright (C) 1984, 2021 by Lugaru Software Ltd. All rights reserved.