Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

What does evaluation mean? post, pre ++ --

 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Could anybody make me understand what does evaluation mean? It is said, the expression is first evaluated from left to right ... Is value is put at the time of evalution. Give a example please.
Little descriotion would be appreciated.


Thanks and Regargs,
cmbhatt
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An opration like variable++ would change the value of the variable in the next line. An operation like ++variable will change the value of the variable immediately on the same line.

int x=0;
x++; - value of x is 1 in the next line
int y=0;
++y; - value of y is 1 here
 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks John,

Does next line increment also include the same line in postfix while there are sevaral post increment operaions like:

int x=1;
int y= x++ + x++ + ++x + x++;


Please clarify, how will the above expression be "evaluated"?

Thanks and Regards,
cmbhatt
 
chintan ramavat
Ranch Hand
Posts: 134
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its very important to make it clear

x = 3

y = x ++ ; // y = 3 ;
y = ++ x ; // y = 4 ;

value wont be incremented in the first expression but in the second it will be incremented first and then assigned to x.


hope it helped
chintan
 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Chandra Bhatt:
...how will the above expression be "evaluated"?


 
Chandra Bhatt
Ranch Hand
Posts: 1710
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Marc,

The way you answered was what I expected.




Thanks and Regards,
cmbhatt
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic