Article View: comp.std.c
Article #2230Re: comment style
From: Ron Irvine
Date: Fri, 04 Jan 1991 16:43
Date: Fri, 04 Jan 1991 16:43
39 lines
1431 bytes
1431 bytes
A need for // (real) comments:
#include <stdio.h>
void main() {
int *p;
int a;
int f = 10;
int n = 5;
p = &f;
a = 100/*p /* calculate first factor */
+ 25/n; /* and second factor */
printf("The answer is %d, %s\n", a, (a==15)?"OK":"BAD");
}
The actual program that contained this problem was very complex.
It took two of us a day to figure out what had happened.
Flame On:
It is incredibly STUPID to have the start of comment token the same
as a LEGAL combination of other language tokens.
I have run this program on 4 different C compilers and none of them
even warned of a potential problem (nested comments).
Comments are part of the syntax of the language and should never
have been left to the EVIL pre-processor to "handle".
Flame Off:
The // comment style should have been adopted by the ANSI committee
if for no other reason that to reduce the likelihood of a programmer
falling into this horrendous trap. If // style comments had been
used in the above program the compile would have failed.
Ron Irvine, ron@sco.com
Technical Details
Message-ID:
<1991Jan04.164355.15674@sco.COM>Path:
arc1-ca.pugleaf.net!utzoo!attcan!ncrcan!scocan!ronShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!attcan!ncrcan!scocan!ron From: ron@scocan.sco.COM (Ron Irvine) Newsgroups: comp.std.c Subject: Re: comment style Message-ID: <1991Jan04.164355.15674@sco.COM> Date: 4 Jan 91 16:43:55 GMT Sender: news@sco.COM (News administration) Organization: SCO Canada, Inc. (formerly HCR Corporation) Lines: 39 Originator: ron@capri