"C" wish list/semicolons
Lowell Savage
savage at ssc-vax.UUCP
Thu Nov 7 06:49:56 AEST 1985
>
> The thing to remember is that PEOPLE are the most important readers of a
> program. If they can't read and understand it, they can't maintain it.
> Taking that into account, the best thing for semicolons is:
>
> Let them separate two staments on the same line. Let line breaks
> terminate statements if it makes sense to do so.
>
> For example, a block could look like:
>
> {
> x = 23; y = 40
> z = x + y
> printf("Messy Format", x, y, z,
> f) /* Statement didn't end, as it wouldn't parse */
> f = x + 7 /* Does this end? */
> * y /* Uh, no... */
> }
That's fine, but what about this:
{
x = 23 + 7 /* Does this end? */
* y = 40 /* Or do we multiply by y which is contains the value
40...or is this simply an error?? */
}
What semicolons do is remove ambiguity (even if it is only partial). If
semicolons (or other statement separator or terminator) is explicitly
required by the syntax of the language, then the reader doesn't have to
go through "is y a pointer or is it an integer" before he can determine
where how many statements he has. Also, can you imagine how hard it
would be to right a compiler that would do all of that kind of semantic
processing to find stuff like that? And error recovery?
> No mess, no sweat when adding statements. Fewer kestrokes, and it's easier
> to read than either other version.
Sorry, I disagree.
> Since modern languages like CLU, Icon and BCPL (BCPL! Waitaminute!) allow
> this, I think it belongs on any C wish list.
You mean that they have *NO* statement terminator or separator??!! (Sorry
if I'm exposing my ignorance on these languages.) If so, then they must
have some other way of resolving ambiguities like the example above.
These are my own personal biases. Anyone that wants to share them will
have to fill out a 100-page non-disclosure agreement in octuplicate
(without carbons), send all copies with 2 dollars for processing to
outer Tanzania, wait two years, and chant "Mousy Dung was a bad guy."
five hundred times. All questions on this matter will be refered to
the Bureau of non-violent violence (BNVV)...or was that the Association
for the Promulgation of Persons Against Associations (APPAA)?
There's more than one way to be savage
Lowell Savage
More information about the Comp.lang.c
mailing list