Why nested comments not allowed?
Russel Dalenberg
dalenber at cbnewsc.ATT.COM
Sat Mar 3 12:22:33 AEST 1990
In article <4686 at jarthur.Claremont.EDU>, dfoster at jarthur.Claremont.EDU (Derek R. Foster) writes:
> If people wish to argue about the aesthetics of nested comments vs.
> #ifdef/#endif, that's fine, but arguments like
>
> "But with nested (or "but with non-nested...") comments, how can I do
> printf("/* some horrible abomination with lots of /* and */ */");
>
> are NOT MEANINGFUL, since the same problems exist with/without nested
> comments, just in different situations!
I agree. I only posted my printf example to point out that parsing
nested comments would not be "simple".
> And it's the code-writer's fault!
Well, in the sense that all the code a programmer writes is his "fault", I
agree. But I think it's perfectly reasonable to put comment delimiters in
a string (and quotes in comments).
> 4) If you write code that depends on whether comments are nested or not,
> it's not the compiler's fault, it's YOURS, and you deserve what you get!
No. Comments in C are *defined* not to nest. It's perfectly reasonable to
expect then not to nest, and program accordingly.
> Encode /* and */ before putting them in strings!
I think this is foolish overkill. It can't hurt your code, but it can
make it harder to read and maintain.
Russel Dalenberg
att!ihlpb!dalenber
dalenber at ihlpb.att.com
Disclaimer: These are my opinions, not AT&T's
More information about the Comp.lang.c
mailing list