Why nested comments not allowed?
bethge at wums.wustl.edu
bethge at wums.wustl.edu
Sat Feb 17 08:36:34 AEST 1990
In article <1523 at wacsvax.OZ>, chris at wacsvax.OZ (chris mcdonald) writes:
> raw at math.arizona.edu (Rich Walters) writes:
>>In article <236100027 at prism> ly at prism.TMC.COM writes:
>>> I'm just curious to know why nested comments are not allowed in many
>>> languages.
>>Nested comments are not supported because it is difficult to tell where the
>>nesting ends. Have you ever written a paren checker in C? (in any language?)
>>Reason 2) Why waste the computing power?? After all, it's only a comment!!
> What a stupid response!
> I don't know why they are not supported but agree that they are damn
> useful. They are easy to parse in syntactically correct programs (ever
> heard of counting?) and, after all, the computer/compiler is supposed to
> do what we tell it, not for us to bow down and minimize its work.
> If its really too hard for you to count comments I'll sell you a little
> parser for a ridiculous amount.
I must be missing something here. What are nested comments good for? The only
use I can think of is "commenting out" a section of code which already
contains comments. But C has #if ... #endif for this purpose. So what's the
problem?
One minor thing that has always annoyed me about C is that it takes *four*
keystrokes, two shifted and two unshifted, to make a comment. I know, *if*
one has a smart enough editor one can define a macro to do it. But it also
doesn't leave much space for end-of-line comments in indented code.
IMO the only suitable comment delimiters are <some-reserved-single-character>
and <end-of-line>. This convention saves keystrokes and space, and avoids the
hazard of accidentally "commenting out" a section of code with a defective
comment terminator. Of course, it's a problem for C, which already uses just
about every character in the ASCII set! :-)
More information about the Comp.lang.c
mailing list