Version française
Home     About     Download     Resources     Contact us    
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: Basile STARYNKEVITCH <basile@s...>
Subject: Re: [Caml-list] single-line comment request
>>>>> "Nickolay" == Nickolay Semyonov-Kolchin <snob@snob.spb.ru> writes:

    Nickolay> On Tuesday 08 April 2003 22:31, Chris Hecker wrote:
    Chris>>  Hmm, I just did a quick test to check the assumption of
    Chris>> whether single-line comments are more common.  In my code, 86%
    Chris>> of comments are single line. [...]

I also have many single line comments

    Nickolay> This is serious technical motivation to implement
    Nickolay> single-line comments in language.

I agree, but will make a few remarks: 

adding single-line comment is trivial to do; for example, to add ##
comments just add the following UNTESTED line to ocaml/lex/lexer.mll
(after rule main = parse near line 90)

   "##" [ ^ '\n' '\r' ] + { main lexbuf }

the problem is to agree for a lexing comment rule which won't break a
lot of existing code. I have no idea if ## is not already used in some
existing code somewhere. (And it is not definable as an infix
operator). Of course, the problem is to avoid clashes with practical
use of the infix operator syntax in Ocaml.

perhaps we might agree on a triple character comment starter if a
double character is not enough.

Egoistically, as a user of a French AZERTY keyboard, I tend to dislike
the # char since it require a double-keystroke (# is AltGr " on AZERTY
keyboards). 

I also suggest the following di-graph for comments
  ## as suggested before
  #! (which is compatible with Unix first line execve convention)
  -- (which is like comments in Ada and Haskell)
  // (reminding of Java & C++)
  %%
  |* for the visual effect
  !! (old Basic had single ! for comment)

For tri-graph starting line comments we could consider
  --- 
  ***
  |||
  ///
  -*-
  [*]

I'm sorry for this posting (which is a bit silly or at least
unimportant, as the whole thread). The major point is to reach an
agreement; once we've got an agreement which don't break a lot of code
implementing such one-line comments is a matter of minutes. (Of
course, extending the Emacs & Vim mode for emacs is a bit harder).

Regards.
-- 

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/ 
email: basile<at>starynkevitch<dot>net 
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Faïencerie, 92340 Bourg La Reine, France

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners