This one bit me today

Craig Jackson drilex1 dricejb at drilex.UUCP
Sun Oct 8 23:28:00 AEST 1989


In article <504 at oglvee.UUCP> norm at oglvee.UUCP (Norman Joseph) writes:
>From article <2432 at hub.UUCP>, by dougp at voodoo.ucsb.edu:
>> -Message-Text-Follows-
>> main()
>>   {
>>   int a=1,b=2,*p=&a,c;
>>   c=b/*p;
>>   }
>> 
>> First real flaw in the C grammer I have found.

A friend of mine was bit by this around 1981.  I was rather amused then,
both by the grot it shows in C, and the two days it took him to not find
it before he came to me.

>I think it's just as fair to say that the fault lies not in the Grammar
>but in the Programmer (with apologies to Shakespeare).  Not only would
>the judicious use of white space have prevented this "flaw", but it makes
>good sense for readability & maintenance.

The question is not one of coding style, it is one of language ambiguity vs
language style.  In C, it is normally acceptable to elide whitespace between
tokens.  Even in the case of characters which may be one token or two, such
as '+', it can be handled.  There is one and only one parse for a+++b.

But since /* is such a powerful token (being handled in the preprocessor, etc.)
C cannot resolve this otherwise normal expression.

Yes, whitespace cures it.  But it is a wart that it needs curing at all.

>What makes people afraid to hit the space bar?  Is it sloth, or ignorance?

I saw nothing that indicated that the poster was afraid to hit the space
bar.  Just that he had not done so *in this instance*.  Can you truthfully
say that you have placed at least one space in each place where one was 
allowed in every C program you have written?  I haven't; the necessity of
doing so makes languages like SNOBOL4 annoying.

>-- 
>Norm Joseph - Oglevee Computer System, Inc.
>  UUCP: ...!{pitt,cgh}!amanue!oglvee!norm


-- 
Craig Jackson
dricejb at drilex.dri.mgh.com
{bbn,ll-xn,axiom,redsox,atexnet,ka3ovk}!drilex!{dricej,dricejb}



More information about the Comp.lang.c mailing list