Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!thunder.mcrcim.mcgill.edu!snorkelwacker.mit.edu!usc!cs.utexas.edu!asuvax!noao!arizona!dave From: dave@cs.arizona.edu (Dave P. Schaumann) Newsgroups: comp.std.c Subject: Re: C needs reliable comments Message-ID: <724@caslon.cs.arizona.edu> Date: 24 Jan 91 00:14:23 GMT References: <2893@cirrusl.UUCP> <14884@smoke.brl.mil> <2915@cirrusl.UUCP> Organization: U of Arizona CS Dept, Tucson Lines: 57 In article <2915@cirrusl.UUCP> dhesi%cirrusl@oliveb.ATC.olivetti.com (Rahul Dhesi) writes: |I wrote (among other things): | | (b) You can use #if 0 and #endif to comment out a block of code. | Then if you have an invalid token or unbalanced quotes between | these, the "commented out" block of code, the compiler may abort | compilation. | |In <14884@smoke.brl.mil| gwyn@smoke.brl.mil (Doug Gwyn) responds: | ||This is fallacious. If you start with valid code and "comment out" a ||section to leave valid code using #if 0 and #endif, there is no problem. ||If you wish to adopt the thesis that random character strings should be ||accepted as valid C program source code, you're [name-calling deleted]. | |If you have C code and isn't working right, you may want to temporarily |comment it out and replace it with a working stub. No. Not comment out. I would use the conditional compilation operators, though. |Furthermore, the term "code" includes not only the C part but also any |other text that is part of a C source file but is not intended for the |compiler. Maybe for you. The way I (and obviously ANSI) see it, is that code is code, and comments are comments, and never the twain shall meet. Comments can be *any* text (except, of course, the comment-end delimiter. If you want to include something that is a comment, use /* */. If you want to include something that is *code* (ie at least well formed tokens), use the #if/#endif operators. I think that ANSI is well within the bounds of reasonableness to require that everything within the conditional compilation operators be well formed tokens. After all, it is supposed to be code -- something that (perhaps, with a little work) someday will be compiled. | [example of comment/conditional compilation use deleted] C is certainly not perfect. No language is. Comments cannot include random text, and it is certainly reasonable that article headers and signatures might contain "*/". Personnaly, I strip off the non-code portions in this case, and save them to a seperate file. This is my final word on this thread: (I promise :) -comments are for hiding non-program text from the compiler. -the conditional compilation directives are for hiding code from the compiler. If you try to use one for the other's job, *you will have problems*. |Rahul Dhesi