Monday, September 19, 2011

Functional Evaluation

I have some iPad development to do in the near future and I need to learn Objective C. Since Objective C is a super-set of the C programming language, I figured I would finally work my way through the KnR C book. I taught myself how to program in C, which means I most certainly have some gaps in my knowledge that could be filled.

This is one of those embarrassing gaps that falls into the "everyone probably knew this but me" file...

 Somewhere at the end of chapter 2 it says:

"C, like most languages, does not specify the order in which the operands of an operator are evaluated. (The exceptions are &&, ||, ?:, and ',' .) For example in a statement like x = f( ) + g( ); f may be evaluated before g or vice versa; thus if either f or g alters a variable on which the other depends, x can depend on the order of the evaluation." 

This whole time I had naively assumed that evaluation was always done from left to right...

No comments: