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 ?

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is OffTrackbacks are On Pingbacks are On Refbacks are Off Forum Rules

 Similar Threads Thread Thread Starter Forum Replies Last Post Shivanand Kadwadkar C Programming 2 01-01-2011 07:50 PM david ullua C Programming 13 03-01-2006 11:02 PM Ilias Lazaridis Python 2 04-24-2005 05:29 PM Ilias Lazaridis Ruby 18 04-09-2005 04:45 PM Ilias Lazaridis Ruby 74 04-04-2005 05:29 PM