comment style

Dan Bernstein brnstnd at kramden.acf.nyu.edu
Mon Jan 7 12:40:47 AEST 1991


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. // cannot be a substring of non-quoted C code that would be legal if
the language didn't have comments. /* can. (This is just an obfuscated
way of saying ``/* often produces errors because x/*p is legal.'')

2. // is shorter and easier to type than /* */.

3. // is more visually striking than /* ... */.

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 */.

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

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.

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.

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



More information about the Comp.std.c mailing list