|  |  6.3.2 Evaluation of logical expressions 
All arguments of a logical expression are first evaluated and
then the value of the logical expression is determined. For example, the
logical expressions (a || b)is evaluated by first evaluatingaandb, even though the value ofbhas no
influence on the value of(a || b), ifaevaluates to
true. 
Note, that this evaluation is different from the left-to-right,
conditional evaluation of logical expressions (as found in most
programming languages). For example, in these other languages, the value
of (1 || b)is determined without ever evaluatingb.  This
causes some problems with boolean tests on variables, which might not be
defined at evaluation time. For example, the following results in an
error, if the variableiis undefined: 
 |  | if (defined(i) && i > 0) {} // WRONG!!!
 | 
 
This must be written instead as:
 
 |  | if (defined(i))
{
  if (i > 0) {}
}
 | 
 
However, there are several short work-arounds for this problem:
 
If a variable (say, i) is only to be used as a boolean flag, then
define (value is TRUE) and undefine (value is FALSE)iinstead of
assigning a value. Using this scheme, it is sufficient to simply write
 
in order to check whether iis TRUE. Use the commandkillto undefine a variable, i.e. to assign it a FALSE value (see  kill).
If a variable  can have more than two values, then
define it, if necessary, before it is used for the first time.
For example, if the following is used within a procedure
 |  | if (! defined(DEBUG)) { int DEBUG = 1;}
...
if (DEBUG == 3)  {...}
if (DEBUG == 2)  {...}
...
 | 
 
then a user of this procedure does not need to care about the existence
of the DEBUGvariable -- this remains hidden from the
user. However, ifDEBUGexists globally, then its local default
value is overwritten by its global one. 
 |