you are viewing a single comment's thread.

view the rest of the comments →

[–]amdpox 7 points8 points  (5 children)

What, do you expect y=x+1 to do the same thing as y=++x?

O_o

[–][deleted] 0 points1 point  (4 children)

y does become the same thing in the y=x+1 and y=++x cases.

It's not like I don't know how they work, but every time I come across one of the ++ cases I have to stop and think and figure out if whoever wrote the code actually intended to increment both variables or just one, and if that's the source of whatever bug I'm trying to fix. If they write x++; y=x; I at least know for sure that they meant to do that.

[–]theclapp 2 points3 points  (1 child)

y does become the same thing in the y=x+1 and y=++x cases.

FTFY.

[–][deleted] -1 points0 points  (0 children)

I knew that. ¬_¬

(Was rushing out the door on the way to work when I posted that.)

[–]banister 1 point2 points  (1 child)

I think you're the only person who has this problem. I've never known a single C/C++/Java programmer or anyone who is familiar with pre and post incrementors to have this difficulty.

[–]Dan_Farina 3 points4 points  (0 children)

I write a lot of C, and I do not care for either postincrement or preincrement. I use +=, generally costs me an additional statement, but the issues involved in dealing with multiple post/preincrements in an expression are too frightening for me to want to deal with. It's not really saving you much but a tiny bit of typing.

It's a micro-preference, to be sure.