Path: utzoo!attcan!uunet!samsung!zaphod.mps.ohio-state.edu!mips!bridge2!jarthur!dfoster From: dfoster@jarthur.Claremont.EDU (Derek R. Foster) Newsgroups: comp.lang.c Subject: Re: Re^2: Why nested comments not allowed? Message-ID: <4509@jarthur.Claremont.EDU> Date: 20 Feb 90 17:39:23 GMT References: <1523@wacsvax.OZ> <13706@cbnewsc.ATT.COM> <4286@jhunix.HCF.JHU.EDU> Organization: Harvey Mudd College, Claremont, CA 91711 Lines: 32 >In article <13706@cbnewsc.ATT.COM> dalenber@cbnewsc.ATT.COM (Russel Dalenberg) writes: >>And what will you do when trying to comment out code that contains the >>"end of comment" sequence? >> printf("A comment is ended with */"); Maybe I'm just strange, but I think that this whole issue of "what will you do if your code contains start/end comment characters" is missing an important point. It seems to me that putting a start or end comment in a string literal (like above) is a HORRIBLE programming practice whether you can have nested comments or not. It's just asking to be accidentally matched with some other part of a comment. Couldn't you avoid the whole issue by just doing something like : printf("A comment is ended with *\/"); (I'm not sure if this is portable) or else you could just go printf("A comment is ended with *""/"); or else, as a last resort, printf("A comment is ended with *%c",'/'); These don't seem like too much trouble given the relatively few times you will ever need to do this, and they will not only save you from problems with nested comments (now, your code doesn't care), it will also save you from potentially forgetting to close one of your comments, only to have it matched somewhere you didn't expect... Just my 2c. Derek Foster