Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] single-line comment request
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <brian.hurt@q...>
Subject: Re: [Caml-list] single-line comment request
On Tue, 8 Apr 2003, Chris Hecker wrote:

> >Again, this extension is purely stylish.
> Actually, just to fuel the fire, it's not just stylish.  Single-line 
> comments are sometimes easier to work with programmatically 

Not noticeably in my experience.

> (no need to 
> count {[()]} to see where the comment ends, 

This is only relevent if you're parsing the file.  If you are parsing the 
file, I'm assuming you have at least regular expressions, if not a full 
on lex/yacc combination.  So counting fences isn't that big of a problem.  
Vim's syntax highlighting seems to work just fine (well, except for 
*really* long comments).

> rectangular editing commands 
> can comment and uncomment blocks, 

Adding (* before the block and *) after is so difficult?

> end of line is sometimes ragged so 
> commenting out cannot be done linearly without editor macro trickery, 

Hmm.  I wouldn't have called finding the end of a line 'editor macro 
trickery'.  In vi, it's just $.  Or, from anywhere in line, hit 'A' and 
automatically append to the end of the line.  In emacs, C-E jumps you to 
the end of the line, IIRC.

> wasted characters and movement for single line comments (which I would 
> assume are the majority of comments by number, if not by lines), 

Three.  Space, asterix, close paren.  

> etc.).  Also, using camlp4 for this slows down compiles.

All of the above might be an argument for doing single-line comments
*instead of* multiline comments.  Let me just get some plutonium for the
Delorean and we can go back to 1985 and change that design decision.

Now: here's a counter argument to adding single line comments: backwards 
compatibility.  While Ocaml-3.07 may support single line comments, 
Ocaml-3.06 doesn't, and by definition never will.  So code with single 
line comments will never run on Ocaml-3.06, despite the fact that except 
for single line comments, there is no other compatibility problems.  And 
there are reasons to still be using older versions of Ocaml- Jocaml being 
one of them.

I'm not opposed to breaking backwards compatibility- I just want something 
valuable in return.

> I would assume there are lots of two-character combinations that are 
> invalid and that don't hose cpp, like "(|" which is even a bit iconographic 
> for the task, in my opinion.  Somebody better at compilers than me could 
> probably write a program to parse the .y and .l files and generate all 
> unused and invalid two-character combinations.

Or just check out page 91 of the language standard.

> Hmm, I just did a quick test to check the assumption of whether single-line 
> comments are more common.  In my code, 86% of comments are single line.  In 
> the compiler bytecomp directory, 89% are single line.  Make of that what 
> you will.

Um, that it's not hard to write single-line comments without a special 
single line comment delimiter?


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: