Standardization questions -- nested comments

Ron Natalie <ron> ron at brl-tgr.ARPA
Thu Oct 18 06:03:05 AEST 1984


> The serious problem with no nesting is that whether or not a comment
> will work or net depends on the context.

Correct, and all you are doing is changing the context rules from one to
another by making comments nest.

> The #ifdef method is
> ugly, and only works for sure if you never use comments or keep them
> real short.  If there is any chance that a comment may be lurking
> around, one cannot just stick a comment string into a C file without
> checking an arbitrarily large amount of context information to see
> if there is another comment that it will mung.

Eh?  #ifdef only has the problem that C has in general, unterminated
comments.  A lint warning about comment ambiguity is required whether
you nest or not.

If you don't nest (current):

	/* COMMENT
		comment_code;  /*  Comment in comment */
	 */

The comment is terminated early and the */ is unexpected and generates
a comile error or
	/*  Comment missing end.
	real_code;	/*  Comment */

No compile error results but read_code gets mysteriously deleted.

If you do nest:
	/*  Commented code	/* commented comment */
	real_code
rest of the file gets eaten (but doesn't if you use the current correct
syntax)... etc...

You probably need to be able to get nit-picking warnings about comments
in comments, comments unterminated at end of file, etc...

Just anot her gratuitous change to the C language that breaks existing
correct code and does not really solve any problems.


-Ron "Let's keep C, C." Natalie



More information about the Comp.lang.c mailing list