"C" wish list/semicolons

Mike I'll be mellow when I'm dead Meyer mwm at ucbopal.BERKELEY.EDU
Wed Nov 6 14:13:06 AEST 1985


Humbug! People arguing about whether semicolons should separate or terminate
statements are in the same class as people arguing whether 8080's or 6502's
are the microprocessor of choice. There's a commonly used better way than
either alternative.

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... */
	}

No mess, no sweat when adding statements. Fewer kestrokes, and it's easier
to read than either other version.

Since modern languages like CLU, Icon and BCPL (BCPL! Waitaminute!) allow
this, I think it belongs on any C wish list. Note that it wouldn't break
existing programs, either (well, I *hope* it wouldn't, but C expression are
such a mess that it might. Moving one token one line should fix things in all
cases).

Note: I haven't considered all the problems implicit in doing this in C. I'd
rather work on modern languages. But this started as a "wish list."

Second Note: The example was chosen to illustrate the features, not for
readability. If you think putting semicolens at the end of each statement
will improve the readability of the example, you have my sympathy.

	<mike

P.S. No, I don't know why this disappeared between BCPL and C (at which
step?). Anyone care to explain?



More information about the Comp.lang.c mailing list