Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Posting-Version: version B 2.10 5/3/83 based; site hou2g.UUCP
Path: utzoo!linus!philabs!cmcl2!floyd!vax135!houxz!houxm!hou2g!mnc
From: mnc@hou2g.UUCP (#M.CONDICT)
Newsgroups: net.lang.c
Subject: Re: Algol-style vs C-style semicolons - (nf)
Message-ID: <270@hou2g.UUCP>
Date: Fri, 8-Jun-84 12:52:48 EDT
Article-I.D.: hou2g.270
Posted: Fri Jun  8 12:52:48 1984
Date-Received: Sat, 9-Jun-84 08:08:59 EDT
References: <3000028@uokvax.UUCP>
Organization: AT&T Bell Labs, Holmdel NJ
Lines: 31

Not wishing to drag out a rather uninteresting discussion but unable to
resist pontificating on language design matters, I submit the following
on the semicolon controversy.  It is true that semicolons are not, strictly
speaking, statement terminators in C, because not all statements end with
them.  In fact, a quick look at the grammar in the C Reference Manual shows
that only the following statements are terminated with semicolons:

	expression ;
	do statement while ( expression ) ;  /* This one was new to me! */
	return expr ;
	goto identifier ;
	continue ;
	break ;
	;			/* A null statement */

The rest, including for loops, while loops and compound statements are not.
It is the presence of null statements that confuses the matter by making
people think that

	while ( expr ) statement ;

is one statement and is terminated with a semicolon, when in fact it is
two statements -- a while loop followed by a null statement.

Can anyone explain why, of all the loop statements, only do-while is
terminated with semicolon?  The required closing right-paren would seem
sufficient for easy parsing.

Michael Condict    allegra!hou2g!mnc
AT&T Bell Labs,
Holmdel