Path: utzoo!attcan!uunet!cs.utexas.edu!usc!ucsd!ames!ads.com!sparkyfs!mckenney From: mckenney@sparkyfs.istc.sri.com (Paul Mckenney) Newsgroups: comp.lang.c++ Subject: Re: // and phases of translation Message-ID: <32374@sparkyfs.istc.sri.com> Date: 28 Jun 90 19:09:35 GMT References: <1580@io.UUCP> <804@mwtech.UUCP> Reply-To: mckenney@itstd.sri.com (Paul E. McKenney) Organization: SRI International, Menlo Park, CA 94025 Lines: 65 In article <804@mwtech.UUCP> martin@mwtech.UUCP (Martin Weitzel) writes: >In article <1580@io.UUCP> jar@io.UUCP (Jim Roskind x5570) writes: >>> >>> Jun 15 15:42:00 1990 Richard Man inmet.inmet.com!rich writes: >>> >[about // comments] >Though I don't have practical experience with C++, I know about its >key features. The idea of //-comments allways appealed to me, but I >can't see why they are so problematic. (Well, I see that there may >arise problems from a theoretical point of view.) >IMHO such comments should modell the expectations of the majority of >users (ie. programmers). Now, what *are* the expectations of the >majority? I suspect that the majority of users need not deal with multi-line macros often, and I hope that the fraction of users that must work with such things declines sharply once templates become available. The problems with //-comments only appear in conjuntion with continuation lines, which are needed mostly for multiline macros (they are no longer needed for multiline strings). So I would expect that the majority of programmers would be satisfied with any of the solutions that have been advanced. >This questions turns out to have a simple answer (again "IMHO", of >course :-)): >Many of us work not only with C, but also with the UNIX SHELL, AWK, >MAKE, ... and there *are* exactly such comments in all these programs >(except that they start with '#'). The manual tells that such comments >terminate at the end of line, but they *don't* say that the Newline is >*discarded* (in fact, it isn't). I agree that this is the way these tools handle such comments, but I have the same objection to it as I do to the way C++ handles //-comments. If I have a long, multiline command in an ``sh'' script, I cannot comment parts of the command -- any comment I supply will terminate the command. This behavior is especially annoying when I need to use complex commands with obscure syntax such as ``find''. ``awk'' does not pose so much of a problem, as multiline commands can usually be broken down into single-line commands through use of temporaries or loop-exit constructs. Then comments may be placed between the resulting separate statements without problems. ``make'' ends up working well, perhaps by accident... Escaped newlines are needed to allow if's and for's in the shell commands. Comments that appear on the ends of these lines are passed uninterpreted to ``sh'', but after the backslashes have been stripped. Thus, these comments do not interfere with the continuation. >If I use any of the above tools a `#......Newline'-comment would never >introduce a continuation line. So it shouldn't do so in C++ -- or it will >counter-intuitive to all with only slight experience from Unix tools. People with only slight experience with these tools have most likely not been so unfortunate as to run into a situation where it makes a difference (IMHO, of course!). C++ follows ANSI C in its definition of phases of compilation. Unfortunately, ANSI C does not have //-style comments, so this results in a less-than-useful interaction between //-style comments and continuation lines. Thanx, Paul