[net.lang.c] Strange C parses

wcs@homxa.UUCP (Bill Stewart HO 4K-437 x0705) (04/24/84)

<I wish I could read the article into my temp file.  Oh, well>

This is an reply to the article about why

	int *v, *w;
	x= *v/*w;

treats the /* as a Begincomment token, while
	...
	x= *v/ *w;

works.  (Note that I have x= *v, not x=*v, which still dies on
System V, in violation of the current language definitions.
(So do k=-1; or k=++j; ) )  I assume the reason is that comments are
handled by the lexical analyzer, rather than by the grammar.  While
this is not totally flexible, it's much cleaner to program, and  you
don't get killed by /* stuff with bad(syntax( */.  I think the /*
problem is a tolerable compromise (since I don't use it much);
the =op stuff bugs me.
			Bill Stewart AT&T Bell Labs, Holmdel

jas@drutx.UUCP (ShanklandJA) (04/24/84)

Two quick comments (no pun intended):

First, C comments are handled by the preprocessor, not the lexical analyzer,
at least by default.

Second, I don't want to make excuses for C's little lexical liberties,
but let's not forget that all the examples we've seen are pathological.
Inserting spaces at appropriate places in expressions is part of writing
clear code.  How often have you seen stuff like:

while ((*++c=*f)&&(d=='e'||d=='E')||dptr)  ...

I'm not saying that a programmer with even a little C experience can't
understand the above code fragment; I'm saying it's easier on the eyes
and mind to read:

while ( ( *++c = *f ) && ( d == 'e' || d == 'E' ) || dptr ) ...

Of course, all that white space wastes lots of disk space, but then, so
do comments :-)

Jim Shankland
..!ihnp4!druxy!jas

crane@fortune.UUCP (John Crane) (04/25/84)

So what if white space and comments "waste" disk space? Have you got
something better to put on the disk? Is all this "wasted" space keeping
you from putting something else on the disk.

When you consider what you have to pay another programmer to decipher
code without white space and comments versus the cost of disk space,
you'll find that commenting is a real baragin.