| C Tutorial | C programming cleverness and Ego issues | |||
|
Introduction to C language Integer types Char constants Int constants Type combination and promotion Int overflow Floating point types Comments Variables Assignment operator Truncation Int vs float arithmatic Mathematical operators Unary Increment Operators Pre and Post Variations C Programming Cleverness and Ego Issues Relational Operators Logical Operators Bitwise Operators Other Assignment Operators
|
Relying on the difference between the pre and post variations of these operators is a classic area of C programmer ego showmanship. The syntax is a little tricky. It makes the code a little shorter. These qualities drive some C programmers to show off how clever they are. C invites this sort of thing since the language has many areas (this is just one example) where the programmer can get a complex effect using a code which is short and dense.
If I want j to depend on i's value before the increment, I write...
j = (i + 10); i++;
Or if I want to j to use the value after the increment, I write...
i++; j = (i + 10);
Now then, isn't that nicer? (editorial) Build programs that do something cool rather than programs which flex the language's syntax. Syntax -- who cares?
|
|