Path: utzoo!utgpu!water!watmath!clyde!cbosgd!ihnp4!ihlpf!nevin1 From: nevin1@ihlpf.ATT.COM (00704A-Liber) Newsgroups: comp.lang.c Subject: Re: nested comments Message-ID: <3460@ihlpf.ATT.COM> Date: 21 Jan 88 02:21:54 GMT References: <13423@pyramid.pyramid.com> Reply-To: nevin1@ihlpf.UUCP (00704A-Liber,N.) Organization: AT&T Bell Laboratories - Naperville, Illinois Lines: 58 In article <13423@pyramid.pyramid.com> markhall@pyramid.UUCP (Mark Hall) writes: .I have a brief observation about comment operators, which applies .to C as well as other languages. Rather than suggest that it be .incorporated into ANSI C, I would only like to hear your views, and .either (a) build up some ground swell of support, or (b) discover why .it is a bad idea. . .I would like to give two short arguments for having nested comments. . . 1. it is often convenient to `comment-out' code that already . has comments in it, either because you don't want to RUN the code, . or because you don't want to COMPILE the code. If you don't want to . run the code, you can encircling it like: . if (FALSE) { . . . . offending code with comments . . . . } . but this means that the `offending code' must be syntactically . correct, or the compiler will not produce an executable (even . though the code cannot be executed), so we cannot use this method . when we don't want to compile the offending code. (Note that having . nested comments here would aid appreciably in performing the . `binary bug hunt'.) If you do not want to compile offending code, it would be better to use macros than to comment out the code; i.e., if (FALSE) { #ifndef THIS_IS_CODE_I_DO_NOT_WANT_TO_COMPILE_RIGHT_NOW /*No flames about the obviously long identifier :-)*/ . . . offending code with anything you want . . . #endif } . . 2. using nested comments, you are much less likely to suffer from . mistakes of the form: . a=b; /* <-- comment starts here . c=d; /* comment ends here --> */ . The compiler would, in all likelyhood, run til EOF looking for the . matching comment and, since it knows which begin-comment it is . trying to match, could point back to the offending comment above . and report ``no close comment found matching this fellow''. Yes, but you may introduce errors that LISP programmers sometimes suffer from (by having too many parentheses): If there are too many nested comments, it may become very hard to determine how many end comment markers should be put in and where they should go. The worst problem I can see for nesting comments in C is that it might break existing code. -- _ __ NEVIN J. LIBER ..!ihnp4!ihlpf!nevin1 (312) 510-6194 ' ) ) "The secret compartment of my ring I fill / / _ , __o ____ with an Underdog super-energy pill." / (_