"C" wish list/semicolons

Andrew Koenig ark at alice.UucP
Thu Nov 7 02:28:41 AEST 1985


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

Ummm... the assignment to f is problematic.  Let's change it a bit:

	f = x + 7
		*p++

Now, is this one statement or two?  I strongly suggest that if
you want to have a syntactic rule for continuing a statement,
you make it a lexical rule instead, as in EFL.  Thus, if the
last token on a line is {insert list here}, the statement is
continued.  The list would be exactly those tokens that cannot
ever end a statement, such as ( = + - * / and so on.



More information about the Comp.lang.c mailing list