Wilcox@HI-MULTICS.ARPA (08/05/86)
A recent message noted a "problem" discovered with Pascal. it has to do
with the form and function of the IF - THEN statement. The given
statement had the form:
IF ((p <> NIL) AND (link[p^.lp] = 0)) THEN ...
where p <> NIL is the guard to insure the p^.lp reference does not blow
up. The technique is commonly known as "short-circuiting" and Pascal
has never had it, and probably never will. A number of High level
languages do not allow short-circuiting. SNOBOL is one language that I
can think of offhand that does allow short-circuiting. This shortcoming
of Pascal is more of an inconvienience I think, It would certainly cause
innumerable headaches to those in the debugging business. The solution
of nested IF - THEN statements is one solution, and the other is
(depending on the function of the code) to use the pointer NIL test as
the loop variable. For example:
WHILE ( p <> NIL ) DO
IF link[p^.lp] THEN ...
I really don't believe there is a problem, but rather it's simply a
problem of inadequate documentation. Apollo Pascal (NON STANDARD!)
allows a civilized version of Short-circuiting...
IF (p <> NIL) AND THEN (link[p^.lp]) THEN .... and
IF (p <> NIL) OR ELSE (link[p^.lp]) THEN ...
Check into the manual. It depends on standards and portability in
choosing whether to use the apollo version or use the nested if.
Check a couple of language books, Not reference manuals but language
construction/definition books, and the SNOBOL language reference manual
for further info.......