Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!ucbvax!pasteur!ames!ig!arizona!mike From: mike@arizona.edu (Mike Coffin) Newsgroups: comp.lang.c Subject: Re: Optional semi-colons Message-ID: <10531@megaron.arizona.edu> Date: 28 Apr 89 23:04:38 GMT References: <12856@lanl.gov> Organization: U of Arizona CS Dept, Tucson Lines: 43 From article <12856@lanl.gov>, by jlg@lanl.gov (Jim Giles): > From article <29785@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@arizona.edu Univ. of Ariz. Dept. of Comp. Sci. {allegra,cmcl2}!arizona!mike Tucson, AZ 85721 (602)621-2858