Velocity Reviews > b++ is an operation on b or is it an evaluation of b

# b++ is an operation on b or is it an evaluation of b

daudiam
Junior Member
Join Date: Jan 2010
Posts: 1

 01-01-2010
Here is what I understood
Code:
`c=a+b-c;`
In this, since ';' is the only sequence point here, the order in whuch a,b and c are evaluated is udefined, but the left associativity of + and - ensures that the OPERATION a+b happens before any other operation. Right ?

Now in the following code :
Code:
` a=++b/c*d;`
By the same reasoning, the order of evaluation of b,c and d should be undefined. But in the case of b, evaluating means PERFORMING AN OPERATION (pre-increment) also. Since, an operation is involved, the priority rules will apply. So here, the evaluation of b has to occur before that of c or d as the pre-increment has a higher priority than either * or /.

So does it mean that in such cases, where pre and post increment operators are involved, the priority does decide at least some part of the order of evaluation of the expression (AS EVALUATING OPERANDS HERE INVOLVES AN OPERATION ON THEM, WHICH IS CONTROLLED BY PRIORITY AND ASSOCIATIVITY ?

In essence, it boils down to :

Is ++b treated as an operation on b or as an evaluation of b ?