News for hackers. Stuff that matters.
Re:Let’s Stop Bashing C by antiquark on Friday December 02, 2016 @11:33AM (#13089973)
I figured it would print 2, 1, 0, and was right, yay for me I guess. However my confidence was low.

I agree that you can write confusing code with ++, but that doesn't mean it should be banned! (Like they did with Swift). The ++ operators still are very useful. Also there are arguments that they're more correct than +=1 operations. I see ++ as meaning, "go to the next thing."

For example, the following operation sort of doesn't make sense:

  char c = f();
   c += 1;
Why are we adding an integer to a char? If you really wanted to be type safe, it should be

  c += '\001';
So you're adding a char to a char.

Same goes with pointers. They're memory addresses... but what happens of you add 1 to a memory address? Should you get the address plus one, or should you step over to the next object?

There are no comments on this comment yet.