Closing keywords (was Re: Algol, and language design) (Eliot Moss)
Fri, 27 Jul 90 03:41:15 GMT

          From comp.compilers

Related articles
Closing keywords (was Re: Algol, and language design) (1990-07-27)
Re: Closing keywords (was Re: Algol, and language design)!decvax!decwrl!garth!phipps (1990-08-10)
Re: Closing keywords (was Re: Algol, and language design) (1990-08-14)
| List of all articles for this month |

Newsgroups: comp.arch,comp.compilers
From: (Eliot Moss)
In-Reply-To:'s message of 26 Jul 90 02:44:49 GMT
Followup-To: comp.arch,comp.compilers
Keywords: design, debug
Organization: Dept of Comp and Info Sci, Univ of Mass (Amherst)
References: <> <> <>
Date: Fri, 27 Jul 90 03:41:15 GMT

In the design of CLU we orginally had Algol/Pascal style control construct
syntax, such as "if <expr> then <stmt> else <stmt>" (i.e., without closing
keyword), so that one required a begin/end pair for a then or else action more
than one statement long. Even with single character abbreviations for
begin/end (we used "{" and "}") we felt this was a pain, and while a closing
bracket does mean a little more typing, it is leads to simpler program
modification, especially adding/deleting statements. Having a closing bracket
also resolves the syntactic ambiguity of the "dangling else" in "if .. then ..
if .. then .. else" (i.e., does the else go with the first or second then?). I
have also heard (but do not know a definitive reference; i.e., this is a
rumor) that Wirth said he made a mistake in the Pascal syntax, and fixed it in
Modula-2. Sure enough, Modula-2 and its descendants have closing bracket
control constructs.

It is another matter whether one prefers "if .. fi", "if .. end", "if .. end
if", or "if .. endif", and I doubt we'll ever reach consensus on that.

Related to BEGIN/END blocks is the argument over whether the ";" that follows
some statements should be a separator or a terminator, the difference being
whether it can occur after the last statement in a list. Similar issues arise
with separator tokens in some forms of case statements (see the Modula-3
syntax for examples). It is possible to allow *both* styles with careful
syntax design; Modula-3 (for one) does that. I tend to favor the more uniform
"terminator" style since, again, it makes additions and deletions simpler. CLU
was actually able to *eliminate* the ";" statement separator/terminator,
through *very* careful syntax design (and maybe it required more than one
token lookahead, too; I don't recall clearly). Anyway, that should be enough
grist for another long running and potentially boring usenet interchange ....

J. Eliot B. Moss, Assistant Professor
Department of Computer and Information Science
Lederle Graduate Research Center
University of Massachusetts
Amherst, MA 01003
(413) 545-4206;

Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.