< previous page page_11 next page >

Page 11
if (condition)
   {
   codel
   }
else
   {
   code2
   }
All tokens are followed by a single space. A construct like:
while(condition)
is never written in this form, but always appears as:
while (condition)
Compound C statements are written for legibility by placing separate statements on separate lines. Thus, constructions like:
if (a < b) x++;else {x--; y = stop;}
do not occur, and are written as:
if (a < b)
   x++;
else
   {
   x--;
   y = stop;
   }
Intermediate variables are used liberally, as opposed to the concatenation of function calls. Thus, a construct such as:
w = foo_1 (foo_2 (foo_3 (z)));
will not be found, but will be expanded to:
y = foo_3 (z);
x = foo_2 (y);
w = foo_1 (x);
This practice improves legibility. There is generally no real penalty imposed on performance, since the evaluation of the concatenated functions will be implemented by most C compilers in such a way as to use internal variables to contain the value returned by each function. Thus, temporary variables will be used by the actual machine code in both cases in essentially the same way, regardless of whether they are declared explicitly in the source code or not. The explicit method has the additional advantage of establishing an additional degree of explicit control over the order of evaluation, which can vary with the compiler, often in unpleasantly surprising ways.

 
< previous page page_11 next page >