Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!bionet!agate!twinkies!raymond From: raymond@twinkies.berkeley.edu (Raymond Chen) Newsgroups: comp.lang.c Subject: Re: Why nested comments not allowed? Summary: Too complicated Message-ID: <1990Feb19.221039.4243@agate.berkeley.edu> Date: 19 Feb 90 22:10:39 GMT References: <236100027@prism> <7330017@hpcllak.HP.COM> <1990Feb19.143619.17663@uncecs.edu> Sender: usenet@agate.berkeley.edu (USENET Administrator;;;;ZU44) Reply-To: raymond@math.berkeley.edu (Raymond Chen) Followup-To: /dev/null Organization: U.C. Berkeley Lines: 26 Dear everyone who wants to argue that nested comments are "good", "easy to implement", "has no hidden surprises": Please present a coherent rule for nested comments for which the following lines of code produce "expected" results: int openquote = 34; /* " */ int closequote = 34; /* Also " */ int quote = 34; /* for a good time, type printf("*/ %c",quote) */ /* int doublequote = 34; /* " */ */ /* don't need this one: '"' */ /* printf("*/ is the close-comment token\n"); printf("/* is the \"open-comment\" token\n"); */ Any set of rules for making these pathological cases work "right" will probably be so complicated that nobody will understand them, and in fact you'll have MORE problems with nested comments than you do today (because the current rules are easy to remember). Conclusions: (1) Don't use comments to comment out code. If you need to comment out code, use #if 0 .. #endif. They nest nicely. (2) There exist programs out there whose job is to help catch runaway comments. Use them. I'll send you mine if you want one. -- raymond@math.berkeley.edu mathematician by training, hacker by choice