Boolean operators (Was: Re: New Alpha)

Wed, 16 Apr 1997 23:42:36 +0200 (MET DST)


According to Frank Heckenbach:
> 
> Indeed, I think this is good if one uses complete evaluation by default.
> However, I prefer to have short circuit evaluation by default.
> So what about similar operators to force complete evaluation - it would seem
> cleaner to me than using {$B+} ... {$B-}?

ISO Pascal's short circuit operators are "and_then" and "or_else";
GPC also allows "and then" and "or else".  Perhaps "or_then" and
"and_else" would be their natural counterparts?

BTW, can anybody tell me a case where complete evaluation is desirable?
IMHO, no reasonable Pascal program should use functions with side-effects
in `if' conditions containing `and' because you can never know in which
order they are evaluated (except with short-circuit operators, but here
we are again).

... Ahhh!  8-)  PS: ISO 10206, 6.8.3.1 says:

    NOTE - This means, for example, that the operands [of ordinary `or'
    and `and'] may be evaluated in textual order, or in reverse order,
    or in parallel, or they may not both be evaluated.

This means that short circuit operators being the default does not break
ISO conformance.  Fine.  :-)  AND it means that if you want to produce
portable code you cannot rely on complete evaluation, so be careful.

    Peter

  Dipl.-Phys. Peter Gerwinski, Essen, Germany, free physicist and programmer
peter.gerwinski@uni-essen.de - http://home.pages.de/~peter.gerwinski/ [970201]
 maintainer GNU Pascal [970412] - http://home.pages.de/~gnu-pascal/ [970125]


Peter Gerwinski (peter@agnes.dida.physik.uni-essen.de)

HTML conversion by Lluís de Yzaguirre i Maura
Institut de Lingüística Aplicada - Universitat "Pompeu Fabra"
e-mail: de_yza@upf.es