geoff@desint.UUCP (Geoff Kuenning) (11/19/84)
In article <423@kcl-cs.UUCP> lee@kcl-cs.UUCP (Lee McLoughlin) writes: >>The comment style is the only thing out of Ada I like. I would >>go for that kind of comment style in C too. The /* other kind of */ >>comment is d*mn inconvenient sometimes too. > >I too would like to see a comment style similiar to ada's '--' however a brief >warning I've seen at least one preprocessor for C (I think it was the Equel >preprocessor in the Ingres system) which used '##'. But then again just >about anything chosen runs the risk of clashing with an existing pre-processor. Somebody clever (sorry, I forgot who) suggested '//' for this a month or two ago. I think // is visually much nicer than ##, as well as being much easier to type on reasonable keyboards. -- Geoff Kuenning First Systems Corporation ...!ihnp4!trwrb!desint!geoff
zarth@drutx.UUCP (CovartDL) (11/21/84)
Couldn't you use something like # define // /* to accomplish this. This would also allow you to make anything else comment delimiters rather easy. Seems to simply of a solution, what's wrong with it???? Zarth Arn
gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (11/26/84)
> Couldn't you use something like > > # define // /* Doesn't work!
William LeFebvre <phil@rice.ARPA> (11/26/84)
> > Couldn't you use something like > > > > # define // /* > > Doesn't work! C'mon Doug. The least you could have done is explained why! The ## and // comments are "here-to-end-of-line" comments (thus the name "line comments"). They behave in a fashion similar to the # character in the assembler. When a ## or // appears on a line, it means "everything from here to the newline is a comment." Now you should see why the #define won't work. Where will you get the */ from? BTW: // was used for comments in one of C's ancestors ... BCPL! I could get used to that type of comment again with little problem. But I don't understand the motivation behind such a switch. Is it because people miss the line commenting ability? Is it just because some people think /* */ is too ugly? Or has someone actually been bitten by the expression "c = *a/*b;" ??? :-) William LeFebvre Department of Computer Science Rice University <phil@Rice.arpa>
tom@uwai.UUCP (11/26/84)
> Couldn't you use something like > > # define // /* > > to accomplish this. This would also allow you to make anything else comment > delimiters rather easy. Seems to simply of a solution, what's wrong with it???? > > > Zarth Arn Sorry, the cpp will eat up the /* as a comment rather than doing what you want it to do. -- Tom Christiansen University of Wisconsin Computer Science Systems Lab ...!{allegra,heurikon,ihnp4,seismo,uwm-evax}!uwvax!tom tom@wisc-ai.arpa
ndiamond@watdaisy.UUCP (Norman Diamond) (11/27/84)
> > > Couldn't you use something like > > > > # define // /* > > Doesn't work! > However, #define Comment /* might work. Hard to say whether that would improve readability.
robert@gitpyr.UUCP (Robert Viduya) (11/28/84)
[] An even better idea is to incorporate pattern matching into the C preprocessor. That way you could define your line comments as: #define '##\(.*\)$' '/* \1 */' or #define '//\(.*\)$' '/* \1 */' robert -- Robert Viduya Office of Computing Services Georgia Institute of Technology, Atlanta GA 30332 Phone: (404) 894-4669 ...!{akgua,allegra,amd,hplabs,ihnp4,masscomp,ut-ngp}!gatech!gitpyr!robert ...!{rlgvax,sb1,uf-cgrl,unmvax,ut-sally}!gatech!gitpyr!robert
jim@ISM780B.UUCP (11/28/84)
>Couldn't you use something like > > # define // /* > >to accomplish this. This would also allow you to make anything else comment >delimiters rather easy. Seems to simply of a solution, what's wrong with it???? a) // is not a legal macro name b) /* introduces a comment even for cpp, so it can't be part of defined text c) the desired semantics for // are different (comment terminated by newline) from those of /* (terminated by */) -- Jim Balter, INTERACTIVE Systems (ima!jim)
tim@cmu-cs-k.ARPA (Tim Maroney) (11/30/84)
The objection to: #define // /* is not that cpp will gobble the /*. In fact, most preprocessors allow you to do the following cute trick: #define wombat(x) wombats/**/x so that wombat(fred) expands to wombatsfred. No; the objections are that "//" is not an identifier, and only identifiers may be #define'd; and that it doesn't work (as has been pointed out) to give a line commenting feature. -- Tim Maroney, Carnegie-Mellon University Computation Center ARPA: Tim.Maroney@CMU-CS-K uucp: seismo!cmu-cs-k!tim (supposedly) "Remember all ye that existence is pure joy; that all the sorrows are but as shadows; they pass & are done; but there is that which remains." Liber AL, II:9.
john@physiol.OZ (John Mackin) (11/30/84)
Referrring to: #define // /* <phil@Rice.arpa> writes: > Now you > should see why the #define won't work. Where will you get the */ from? But there are even better reasons: the "/*" will be taken by the cpp to mean "start a comment here"! In other words, all code following will be commented out, up to the next "*/" if there is one. "//" would be defined as a space, IF it was possible to define it at all. K&R, section 12.1: "A control line of the form #define identifier token-string ... " Now, // sure isn't an identifier. (Our cpp calls it an "illegal macro name".) John Mackin, Physiology Department, University of Sydney, Sydney, Australia ...!decvax!mulga!physiol.su.oz!john
William LeFebvre <phil@rice.ARPA> (12/02/84)
Okay, okay. As John Mackin and about 10 others have already pointed out: #define // /* won't work for reasons more fundamental than the one I stated. Forgive me, I sent the letter before I was fully awake. BUT: even IF "//" was a legal identifier, and even IF you could convince the preprocessor to leave the comments in (which you can do with the preprocessor that pcc uses), it still wouldn't work because the semantics are different. Okay? William LeFebvre Department of Computer Science Rice University <phil@Rice.arpa>
david@ukma.UUCP (David Herron) (12/03/84)
Mr. Tim Maroney claims that #define wombat(x) foo/**/x expands to "foobar" when called with "wombat(bar)" because the preprocessor DOESNT gobble up the comment. The EXACT opposite is the truth. The preprocessor gobbles up the comment replacing it with NOTHING. (Another incompatibility between v7 type c compilers and WhiteSmiths. WhiteSmiths compiler replaces the comment above with 1 space). Please people <said with sparks flying> think a little before posting. ----------------------------------------- David Herron; ARPA: "ukma!david"@ANL-MCS (Note the quote marks.) UUCP: unmvax -----------\ UUCP: research ----------\_-_-_-_-_-_-_-_-_ anlams --\ UUCP: boulder -----------/ >-!ukma!david UUCP: decvax!ucbvax ----/ cbosgd!hasmed!qusavx --/