Optional semi-colons

Mike Coffin mike at arizona.edu
Sat Apr 29 09:04:38 AEST 1989


>From article <12856 at lanl.gov>, by jlg at lanl.gov (Jim Giles):
> From article <29785 at apple.Apple.COM> (Peter Desnoyers):
>> A final comment - I spent a lot of time programming in CLU one
>> semester. In CLU, the block structure is unambiguous, and there is no
>> need for statement terminators. The end effect was that the compiler
>> would come up with an error many statements after the incorrect line.
>> It was a royal pain in the butt.
> 
> The same thing happens with C "}" marks - or with Pascal (et.al.) "BEGIN"
> "END" pairs.  It is partly for this reason that most more modern languages
> don't use the 'compound statement' model for flow control constructs.

I don't think so.  The compound statement tends to be easier for
humans to screw up, but it doesn't make error reporting any more
difficult.  The problem with CLU (and SR, which I'm more familiar
with) is that error detection and recovery is much more difficult
without semicolons, even though they're technically redundant.
Both languages allow things like
	a := b + c + (d*e)
		+ f
	/* six pages of comments */
		- g

This is fine as long as there are no errors.  The problem arises when
a line contains a programming mistake, but there is SOME continuation
that would form a syntactically valid statement.  (This happens more
often than you might expect.)  The compiler can't report the error
until it sees that the continuation isn't valid, so it continues to
eat tokens.  When it finally reaches a token that won't fit, it
reports the error --- probably on a line that is perfectly ok.  (The
SR compiler has some messy little hacks to avoid doing this too often,
but it isn't perfect.)

I think the moral is that a little redundancy is a good thing.  If you
don't like semicolons, add redundancy somewhere else.  For instance,
have newlines mark the end of statements unless an explicit
continuation mark appears, as in Fortran. Personally, I think that
"..." on the end of a continued statement would look nice. 

-- 
Mike Coffin				mike at arizona.edu
Univ. of Ariz. Dept. of Comp. Sci.	{allegra,cmcl2}!arizona!mike
Tucson, AZ  85721			(602)621-2858



More information about the Comp.lang.c mailing list