[net.unix-wizards] My Two Cents On Nested Comments

news (12/01/82)

Date: Monday, 29 Nov 1982 14:27-PST

I have to laugh when I see some of the examples that illustrate the
"merits" of nested comments in C. I can't believe they're legible (for
blocking out code) to anyone except the person who wrote them.  And
I've seen plenty of programs where someone cleverly nested comments,
and accidentally cut out part of the code he wanted to include. Better
solutions are:

1)	Use SCCS or RCS, or a similar system.  RCS is public domain,
	so don't say you can't afford it!

2)      Presumably you're blocking out code because it's debugging
	information, or machine-dependent, or the like.  In that case,
	use an #ifdef.  Even if you're just cutting out the line to test
	the effect on the program during development, you'll save
	yourself time by not trying to be tricky with comments.
	Yes, comments are more general (you can block off a "+ 1" in
	the middle of a line), but they are also more error-prone, and
	besides, in any good C programming style, code is spread over
	enough lines so that this seldom matters.

Personally, I'm tired of seeing the message "syntax error" and
having to trace that to an unclosed comment. I'd much rather have
the compiler flag nested comments as errors.

				-- Steve

terryl (12/03/82)

     Well, I must agree that commenting out code for obscure reasons is a
bad practice, and that #ifdef'ing code is better, but I have one complaint
about that: most #ifdef'ed code I've seen is of the form #ifdef machine, or
#ifdef FASTwhatever, which makes the code clear on what it is supposed to
do, but I can't count how many times I've seen code with: #ifdef notdef.
I've always wondered about why people did that. Of course, the code that is
#ifdef'ed that way is never commented. Makes one wonder what the programmer
was trying to convey (or do).

				Never afraid to comment out my name,
				/* Terry Laskodi */

edwards (12/05/82)

#R:sri-unix:-452100:uicsovax:5500050:000:218
uicsovax!edwards    Dec  4 22:12:00 1982


	I agree, but how about changing that compiler error for nested
comments to a warning!  I'd hate to have to go thru MEGA code to take
(/*)'s out of comments.

				Alan Edwards
				(...pur-ee!uiucdcs!uicsovax!edwards)