🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: mod.computers.apollo
1 messages
1 total messages Started by Wilcox Tue, 05 Aug 1986 15:39
Pascal "problem"
#228
Author: Wilcox
Date: Tue, 05 Aug 1986 15:39
33 lines
2106 bytes
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.......
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads