Path: utzoo!attcan!uunet!cs.utexas.edu!usc!brutus.cs.uiuc.edu!jarthur!mti!adrian From: adrian@mti.mti.com (Adrian McCarthy) Newsgroups: comp.lang.c Subject: Re: Nested Comments in C -- A recent experience Message-ID: <953@mti.mti.com> Date: 12 Mar 90 17:26:18 GMT References: <236100027@prism> <1414@amethyst.math.arizona.edu> <1523@wacsvax.OZ> <4320@daffy.cs.wisc.edu> <1990Mar11.065712.9798@usenet.ins.cwru.edu> Reply-To: adrian@mti.UUCP (Adrian McCarthy) Organization: Micro Technology, Anaheim, CA Lines: 33 A nice compiler should warn about "/*" inside of a comment by default. (Of course the user should be able to deactivate this warning if he/she so desires.) The experience recently posted could have been caught with lint or a coverage analyzer or even a debugger in a pretty short amount of time. I'm not so hot on C++'s comment to end-of-line scheme because I often find myself in situations where I want to put a comment in the middle of a line of code. For example: int table [3][3] = { /* 0, 1, 2 */ /* 0 */ { 99, 42, 37}, /* 1 */ { 13, 12, 11}, /* 2 */ { 55, 56, 57} }; or: (void) memcpy(/*targ*/ (void *) &x, /*src*/ (void *) &y, sizeof(y)); I too want something like nesting, so that I can comment out chunks of code rather than #ifdef'ing. But I agree that nested comments are not the answer. Instead I'd like to see two types of comment delimiters (like Pascal), with the restriction that "/*" comments can only be closed by "*/" and that "@@" (or whatever) can only be closed by "@@". If you use the standard comments consistenly for regular types of commenting, and the alternate form for commenting out code, then almost everyone should be happy. In fact, the alternate form could be the C++ scheme of "//" to end-of-line, which is very appropriate for trying to comment out chunks of code. Aid.