Browse thread
Re: per-line comments
- Pierre Weis
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: | 1998-06-23 (00:54) |
From: | Pierre Weis <Pierre.Weis@i...> |
Subject: | Re: per-line comments |
[French abstract ahead] > Caml's comment syntax is more a question of historical tradition than > personal tastes. After all, the comment syntax is perhaps the only > bit of syntax that hasn't changed between LCF ML, Caml, and Standard ML... Even this bit of syntax has changed: LCF ML comments where % blabla % > > but many good programmers use this > > extensively in their in-line documentation. > > I don't quite get the point about in-line documentation. I write > perfectly fine on-line documentation between (* and *). Why would it > be any better with // or -- ? Right. But many programmers feel it simpler to end the comment with a carriage return (if not for the historical trick of being able to put a new instruction after the comment and to reuse the same card upface down! This is a dinosaure's story from the good old time of real computers that knew the meaning of a column :) > At any rate, the main problem with per-line comments (as with most > syntax extension) is that they need a reserved symbol. Both // and -- > are valid OCaml infix identifiers; // is even used in the Num standard > library module. Perfectly exact and pertinent. Even the (* delimitor is a problem when you want to name operators, since (+), (-), (/) work perfectly but you must use extra spaces for the multiplication. However, the old meaning of % in old LCF ML, was carried to Caml, and may be for this historical reason the % character is not in the list of operators for Caml Light or O'Caml. Thus it is usable as a comment delimitor, if not more useful for another purpose. In addition, per-line comments can be a simple way to have comments that are ``free style'' comments, as opposed to the actual comments that must be a suite of lexically correct tokens. Thus it is possible to add per-line comments, but Xavier pointed out the main problem: is it desirable to add this feature to the langage? [Résumé en Français] Xavier a raison: -- et // sont déjà pris. D'ailleurs (* pose déjà un problème avec la syntaxe des opérateurs infixes (il faut écrire ( * ) pour la multiplication alors que ces blancs sont non nécessaires pour les autres opérateurs). Ceci dit % est inutilisé (et il a toujours signifié début de commentaire depuis le début de ML et même en Caml jusqu'à 1991) et pourrait servir à faire des commentaires uni-lignes (et à l'occasion des commentaires qui ne sont pas une suite de lexèmes valides du langage). Mais est-ce vraiment nécessaire ? Pierre Weis INRIA, Projet Cristal, Pierre.Weis@inria.fr, http://pauillac.inria.fr/~weis/