semicolons?

BALDWIN mike at whuxl.UUCP
Thu Nov 7 10:42:15 AEST 1985


> 	Let them separate two staments on the same line. Let line breaks
> 	terminate statements if it makes sense to do so.

I agree!  Awk almost does this; its rules are: semicolons and newlines
terminate statements, and a \ followed by newline is ignored.  The shell
acts like that too, and it will read more lines if it can't complete a
statement.  Seems to work just fine.

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

But "f = x + 7" would be considered a complete statement.  To end up with
a reasonable parser, you have to decide as *soon* as you see the newline
whether you have a stmt or not.  If you want to continue it, put the *
on the end of the line or put a \ there.  If you don't enforce this,
things like the following are ambiguous:

	f = x + 7
	*y++

> 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."

True.  Fat chance in h*ll C will change to do this, and it shouldn't.
But it does make the terminator vs. separator argument look silly.

PS:  If you're *going* to use ; as terminator or separator, I would much
rather it be a terminator, for the sole reason that adding/deleting else
clauses doesn't require mucking up the then clause!
-- 
						Michael Baldwin
						{at&t}!whuxl!mike



More information about the Comp.lang.c mailing list