News for hackers. Stuff that matters.
Re:How to program an NES game in C by greggman on Sunday August 13, 2017 @01:09PM (#15003764)
I'd argue you regardless you should write what you mean

If you mean "increment g" then write "++g"

If you mean "temp = g; increment g; return g" then write "g++"

It doesn't really matter that the compiler may optimize out the "temp". If you're writing "g++" you're indicating you want the value before it's been incremented.

Re:How to program an NES game in C by YSFEJ4SWJUVU6 on Sunday August 13, 2017 @02:00PM (#15004026)
If you're not using the value you can't “want it”. There is only one sane way to interpret the following two expressions statements (in C), and it is that they are equal.

    g++;
    ++g;
Re:How to program an NES game in C by gambiting on Sunday August 13, 2017 @02:15PM (#15004105)
Well, no, you can do stupid code like:

if(g++) {

//do something

}

Which obviously will do something if g was non-zero before incrementing it by one. It's a really poor way of writing code, but I have seen it done.

Re:How to program an NES game in C by chrisseaton on Sunday August 13, 2017 @03:20PM (#15004435)
They said 'if you're not using the value', and you've presented an example where they are using the value, so you're criticism doesn't apply in the case they're talking about.
Re:How to program an NES game in C by YSFEJ4SWJUVU6 on Sunday August 13, 2017 @02:21PM (#15004143)
First of all, I don't agree that code like that is stupid regardless of circumstances. Any programmer worth his salt understands that condition perfectly well without having to think about it.

However, it's an altogether different situation to the one I wrote about, given that the value of the incrementing expression is specifically used in that case.