comment style

Dave P. Schaumann dave at cs.arizona.edu
Mon Jan 7 16:32:32 AEST 1991


In article <1050:Jan701:40:4791 at kramden.acf.nyu.edu> brnstnd at kramden.acf.nyu.edu (Dan Bernstein) writes:
|In article <613 at caslon.cs.arizona.edu| dave at cs.arizona.edu (Dave P. Schaumann) writes:
|| I see no compelling reason to have //, and have heard
|| no argument for // that doesn't boil down to 'I like it that way better'.

|1. [ x/*p can be evaluated as a reasonable expression ]

This is a reasonable argument against why /* is a poor choice as a comment
starter.  However, the time to point this out was 20 years ago, when Dennis
Ritchie was designing C.  Adding // would help you avoid this error, but so
would using white space around binary operators.  (I always do.)

|2. // is shorter and easier to type than /* */.
|3. // is more visually striking than /* ... */.

These are matters of personal taste.

|4. It is always obvious, to both human eye and mechanical parser, where
|a // comment ends (viz., the end of the line). It is not so trivial to
|locate the next */.

My editor has a 'search for text' function.  Doesn't yours?

|5. Placing // at the beginning of several lines is guaranteed to comment
|out the entire section. There is no easily applied rule for /*...*/.

Comments are not for hiding code from the compiler.  #if/#endif and all their
cousins are for that.  Complaining that /* */ doesn't work well to 'comment out
code' is like complaining a socket wrench makes a poor hammer.

|6. An end-of-line comment mechanism can double as the line continuation
|mechanism, as in TeX. This is a beautifully simple way to kill two birds
|with one stone; it cuts the relevant sections of the standard in half.

Unfortunately, I don't know what you are referring to here, so I can't comment.

|7. There's always lots of fuss over matched comments as in C, while
|there's never a fuss over per-line comments as in the shells or TeX.

I agree that it could be easy to misplace a */ when entering code.  However, as
another post points out, // comments can have there own pitfalls when the line
ends with a '\'.

|There. Now you've heard several arguments for // that don't boil down to
|``I like it that way better.'' You may not consider them compelling but
|you can't say they don't exist.
|
|---Dan


Dave Schaumann		| My folks went to uunet.uu.net, but all
dave at cs.arizona.edu	| they got me was this lousy .sig...



More information about the Comp.std.c mailing list