Article View: comp.std.c
Article #2234Re: comment style
From: Dave P. Schaumann
Date: Sat, 05 Jan 1991 22:43
Date: Sat, 05 Jan 1991 22:43
42 lines
1950 bytes
1950 bytes
In article <1991Jan04.164355.15674@sco.COM> ron@scocan.sco.COM (Ron Irvine) writes:
!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 about compilers missing /* within comment deleted ]
The failure, IMHO, is in the compiler for not testing for the sequence /*
within the comment. I think this should be a required feature of every ansi
c compiler. Note that if you are using gcc, -Wall will notify you of this.
!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.
Only if /* */ style comments were not used. Personally, I have no great love
for /* */ comments, but I see no compelling reason to have //, and have heard
no argument for // that doesn't boil down to 'I like it that way better'.
!Ron Irvine, ron@sco.com
Dave Schaumann | You are in a twisty maze of little
dave@cs.arizona.edu | C statements, all different.
Technical Details
Message-ID:
<613@caslon.cs.arizona.edu>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!elroy.jpl.nasa.gov!ames!ncar!noao!arizona!daveReferences:
<1991Jan04.164355.15674@sco.COM>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!clyde.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!apple!usc!elroy.jpl.nasa.gov!ames!ncar!noao!arizona!dave From: dave@cs.arizona.edu (Dave P. Schaumann) Newsgroups: comp.std.c Subject: Re: comment style Summary: No, Virginia, comments do not nest Message-ID: <613@caslon.cs.arizona.edu> Date: 5 Jan 91 22:43:43 GMT References: <1991Jan04.164355.15674@sco.COM> Organization: U of Arizona CS Dept, Tucson Lines: 42