Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > b++ is an operation on b or is it an evaluation of b

Reply
Thread Tools

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

 
 
daudiam daudiam is offline
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 ?
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
sequential-evaluation operation result Shivanand Kadwadkar C Programming 2 01-01-2011 07:50 PM
Does bit operation always work more efficiently than math operation? david ullua C Programming 13 03-01-2006 11:02 PM
[EVALUATION] - E03 - jamLang Evaluation Case Applied to Python Ilias Lazaridis Python 2 04-24-2005 05:29 PM
[EVALUATION] - E04 - jamPersist Evaluation Case Applied to Ruby Ilias Lazaridis Ruby 18 04-09-2005 04:45 PM
[EVALUATION] - E03 - jamLang Evaluation Case Applied to Ruby Ilias Lazaridis Ruby 74 04-04-2005 05:29 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57