Re: The semicolon habit
Mon, 15 May 1995 00:02:17 GMT

          From comp.compilers

Related articles
Re: The semicolon habit (1995-05-10)
Re: The semicolon habit (1995-05-11)
Re: The semicolon habit (1995-05-15)
Re: The semicolon habit (1995-05-17)
| List of all articles for this month |

Newsgroups: comp.compilers
Keywords: syntax, comment
Organization: Australian National University
References: 95-05-074 95-05-084
Date: Mon, 15 May 1995 00:02:17 GMT (Daniel J. Salomon) writes:
>The discussion was more about syntax than about syntax errors. Poor
>syntax can lead to errors that persist until run time. For instance in
>the C language, a programmer may become used to ending every line with
>a semicolon may absentmindedly write:
> while(x < 10.0);
>and not notice the error. There is no syntax error here, but this statement
>is almost certainly a run-time error.

To my mind this is a *semantic* rather than syntactic flaw in C. Indefinite
iteration in which you do nothing is semantically meaningless and the compiler
should flag it as an error. People will say "what about coding an infinite
loop that does ...". Answer: use a different semantic construct (eg. "forever
do"). Indeed almost all the quirky bugs you can get in C through "syntax
mistakes" occur because C's syntax does not adequately reflect the differences
in the underlying semantics of various constructions, chosing instead to use
the same syntax for different semantics ideas. And so you get into trouble.

[Keep in mind that if x is volatile, that's a reasonable thing to write.
It's a subtle issue. -John]

Post a followup to this message

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