Re^2: Why nested comments not allowed?
Jim "Shoe" Schumacher
shoe at hpcllak.HP.COM
Sat Feb 17 14:15:12 AEST 1990
>ly at prism.TMC.COM / 8:21 am Feb 14, 1990 /
>
> I'm just curious to know why nested comments are not allowed in many
> languages.
>----------
You can have some subtle errors with nested comments.
____
{
this was a real **{??/ to write and ..... <- start of nesting
}
<- rest of the file is ignored while we search for the matching brace
and the compiler ends up giving you some really strange error message
about unexpected eof. You go through your code and can't figure out
what it's complaining about.
____
When nesting is allowed you can no longer place any characters you want
in your comments since your text is being scrutinized by the compiler.
The need to nest comments usually arises when you want to comment out
a section of code that contains comments. A better way to do this is
to use a compiler directive like #ifdef.
------
#ifdef 0
code with comments....
#endif
jim shoe (shoe at hpda)
More information about the Comp.lang.c
mailing list