Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!uwm.edu!wuarchive!wums2!bethge From: bethge@wums.wustl.edu Newsgroups: comp.lang.c Subject: Re: Why nested comments not allowed? Message-ID: <1906.25dc1e03@wums.wustl.edu> Date: 16 Feb 90 21:36:34 GMT References: <236100027@prism> <1414@amethyst.math.arizona.edu> <1523@wacsvax.OZ> Lines: 31 In article <1523@wacsvax.OZ>, chris@wacsvax.OZ (chris mcdonald) writes: > raw@math.arizona.edu (Rich Walters) writes: >>In article <236100027@prism> ly@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 and . 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! :-)