[chuck-users] ++ return value
Graham Percival
gpermus at gmail.com
Wed Jun 28 08:41:10 EDT 2006
nitro2k01 wrote:
> The advantage of using the ++ and -- operators is that you can change
> the value of one variable and then further use it in an expression.
> Consider this:
> ++i +=> x;
Wow, you like to live on the edge! :)
Unless I'm vastly mistaken, the code is compiled into exactly the same
assembly commands as
i++;
x+i=>x;
In other words, there's no computational benefit to writing that as a
single statement.
> In many situations, the ++/-- operators lets you write compact
> yet readable code.
I encountered this quote a week ago, and it's already become my favorite
saying: "Debugging is twice as hard as writing the code in the first
place. Therefore, if you write the code as cleverly as possible, you
are, by definition, not smart enough to debug it." - Brian W. Kernighan
I'm all for using ++ and --, but only if they're the only thing
happening on that line. If anything else is happening, I need to
actually think about what's happening, and that's dangerous if you're
trying to write maintainable code. :)
Cheers,
- Graham Percival
More information about the chuck-users
mailing list