Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!usc!apple!snorkelwacker!spdcc!ima!esegue!compilers-sender From: trt@rti.rti.org (Thomas Truscott) Newsgroups: comp.compilers Subject: Re: Semicolons (Re: Low-Rent Syntax) Summary: The real problem is the compiler, not the language Keywords: C, design, debug Message-ID: <4032@rtifs1.UUCP> Date: 24 Aug 90 01:40:41 GMT References: <9008202341.AA06543@llama.ingres.com> Sender: compilers-sender@esegue.segue.boston.ma.us Reply-To: trt@rti.rti.org (Thomas Truscott) Organization: Research Triangle Institute, RTP, NC Lines: 41 Approved: compilers@esegue.segue.boston.ma.us > > while( x );/* a nasty case */ > > x--; > > The real problem here is not with the semicolon, it is with the grammar > production that dominates C and Pascal: The problem is with the compiler that fails to issue warnings about the obvious problems with the above code: prog.c: line 12: degenerate "while" loop prog.c: line 13: dubious indentation level. Tinkering with language syntax can go only a short distance towards stamping out the bugs that typical code contains. Syntax restrictions would be hard put to catch bugs such as: prog.c: line 20: variable "i" may be used before set p = malloc(strlen(s)); ^ prog.c: line 32: was "strlen(s) + 1" intended? I believe this type of diagnostic assistance, fueled by examples of typical errors, is far more effective than adding syntactic handcuffs. I was quite surprised to learn, this evening, of a C compiler that actually does this level of diagnostic analysis. (Along with convenient options to control the degree of nit-picking). Perhaps if it becomes widely available (and demanded), compilers for other languages will do it too, to catch errors such as: while ( x ) y--; endwhile; Tom Truscott [Which compiler is it? And when I really do want to write a degenerate while loop, how do I tell it not to complain? -John] -- Send compilers articles to compilers@esegue.segue.boston.ma.us {ima | spdcc | world}!esegue. Meta-mail to compilers-request@esegue.