* are initial values in class fields mandatory ? (ocaml) @ 1998-06-17 13:17 fbesnard 1998-06-18 2:05 ` Donald Syme 1998-06-18 6:40 ` are initial values in class fields mandatory ? (ocaml) Francois Pessaux 0 siblings, 2 replies; 5+ messages in thread From: fbesnard @ 1998-06-17 13:17 UTC (permalink / raw) To: 'caml-list@inria.fr' I'd like to define a class in Ocaml without giving intial values to its fields. Is it possible ? For example, as far as I've seen, a class with a int and an int list fields would look like this: class dummy () = val mutable v = 0 val mutable l = ([] : int list) end;; but what about a field of type t, for which there is no default value ? i.e. val mutable v = ( ??? : t ) other questions: - are documentations available in pdf (Acrobat Reader) format ? - there is no 'per line' comment (like Ada's "--" or C++'s "//" ) ? ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: are initial values in class fields mandatory ? (ocaml) 1998-06-17 13:17 are initial values in class fields mandatory ? (ocaml) fbesnard @ 1998-06-18 2:05 ` Donald Syme 1998-06-22 8:51 ` per-line comments Xavier Leroy 1998-06-18 6:40 ` are initial values in class fields mandatory ? (ocaml) Francois Pessaux 1 sibling, 1 reply; 5+ messages in thread From: Donald Syme @ 1998-06-18 2:05 UTC (permalink / raw) To: fbesnard; +Cc: 'caml-list@inria.fr' > - there is no 'per line' comment (like Ada's "--" or C++'s "//" ) ? I too think this is a must. It may not quite accord with the personal tastes of the CaML implementors, but many good programmers use this extensively in their in-line documentation. I figure they should be able to transfer their "existing practice" when they make the switch to CaML, just to make the switch as painless as possible. Cheers, Don Syme -- ----------------------------------------------------------------------------- At the lab: At home: The Computer Laboratory Trinity Hall New Museums Site CB2 1TJ University of Cambridge Cambridge, UK CB2 3QG, Cambridge, UK Ph: +44 (0) 1223 334688 Ph: +44 (0) 1223 563783 http://www.cl.cam.ac.uk/users/drs1004/ email: drs1004@cl.cam.ac.uk ----------------------------------------------------------------------------- ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: per-line comments 1998-06-18 2:05 ` Donald Syme @ 1998-06-22 8:51 ` Xavier Leroy 1998-06-23 0:24 ` Pierre Weis 0 siblings, 1 reply; 5+ messages in thread From: Xavier Leroy @ 1998-06-22 8:51 UTC (permalink / raw) To: Donald Syme, fbesnard; +Cc: 'caml-list@inria.fr' > > - there is no 'per line' comment (like Ada's "--" or C++'s "//" ) ? > I too think this is a must. It may not quite accord with the personal > tastes of the CaML implementors, 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... > 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 -- ? > I figure they should be > able to transfer their "existing practice" when they make the switch to > CaML, just to make the switch as painless as possible. Depends from which background you come. E.g. for a well-trained C programmer, delimited comments make more sense. 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. - Xavier Leroy ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: per-line comments 1998-06-22 8:51 ` per-line comments Xavier Leroy @ 1998-06-23 0:24 ` Pierre Weis 0 siblings, 0 replies; 5+ messages in thread From: Pierre Weis @ 1998-06-23 0:24 UTC (permalink / raw) To: Xavier Leroy; +Cc: caml-list [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/ ^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: are initial values in class fields mandatory ? (ocaml) 1998-06-17 13:17 are initial values in class fields mandatory ? (ocaml) fbesnard 1998-06-18 2:05 ` Donald Syme @ 1998-06-18 6:40 ` Francois Pessaux 1 sibling, 0 replies; 5+ messages in thread From: Francois Pessaux @ 1998-06-18 6:40 UTC (permalink / raw) To: fbesnard, caml-list Hello, > I'd like to define a class in Ocaml without giving intial values to its fields. Is it possible ? No > For example, as far as I've seen, a class with a int and an int list fields would look like this: > > class dummy () = > val mutable v = 0 > val mutable l = ([] : int list) > end;; > > > but what about a field of type t, for which there is no default value ? > i.e. > > val mutable v = ( ??? : t ) > That the same problem than trying to create an int ref with no default value. You can't and you don't want ! > other questions: > - are documentations available in pdf (Acrobat Reader) format ? No > - there is no 'per line' comment (like Ada's "--" or C++'s "//" ) ? No -- (* Francois PESSAUX (Francois.Pessaux@inria.fr) *) (* INRIA Rocquencourt - Projet CRISTAL *) (* (http://pauillac.inria.fr/~pessaux) *) ;; ^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~1998-06-23 0:54 UTC | newest] Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1998-06-17 13:17 are initial values in class fields mandatory ? (ocaml) fbesnard 1998-06-18 2:05 ` Donald Syme 1998-06-22 8:51 ` per-line comments Xavier Leroy 1998-06-23 0:24 ` Pierre Weis 1998-06-18 6:40 ` are initial values in class fields mandatory ? (ocaml) Francois Pessaux
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox