Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!samsung!uakari.primate.wisc.edu!sdd.hp.com!hplabs!hpcc01!hpcuhb!hpcllla!hpclisp!hpclscu!shankar From: shankar@hpclscu.HP.COM (Shankar Unni) Newsgroups: comp.lang.c++ Subject: Re: Re: f***ing comments -- another pitfall to avoid Message-ID: <58170022@hpclscu.HP.COM> Date: 30 May 90 18:53:36 GMT References: <31891@sparkyfs.istc.sri.com> Organization: Hewlett-Packard Calif. Language Lab Lines: 43 > I sympathize with your interpretation of how commentmacro should > be expanded, but I dislike the results, to say the least! The effect > is that the first ``//'' comment encountered throws the rest of the > macro definition away. If ``//'' comments are to be useful inside > of macros, they should delete the text up to, but not including, the > first occurance of either a newline or a backslash immediately preceding > a newline. > > This does not really conflict with the ANSI C standard, since ANSI C > does not have ``//'' comments. C++ would of course need to define > the interaction explicitly -- the current smorgasborg of behaviors > is no doubt in part due to the lack of explicit definition. And I sympathise with your "DWIM" interpretation. But remember: a macro definition is technically ONE line. If you embed a "//" comment in there, tough luck: you just lost the rest of the line. Would you embed a "//" comment in the middle of a function call list, like so: foo (x // comment, y, z)? What is the difference between this, and what you are trying to do with your macro? Remember, there is a place for /**/ comments and a place for // comments. The "old-style" comments are by no means second-class in C: they are intended to be used in exactly the situation that you describe: #define longmacro line /* comment */ \ line /* comment */ \ line /* comment */ The most logical (and in my opinion, correct) way to handle macro definitions is to do it as follows: - pull in everything upto a unescaped newline (deleting all \s). - process comments (i.e. strip out /**/ and // comments) ----- Shankar Unni E-Mail: Hewlett-Packard California Language Lab. Internet: shankar@hpda.hp.com Phone : (408) 447-5797 UUCP: ...!hplabs!hpda!shankar