caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* [Caml-list] re: help with ocaml
@ 2001-06-28 16:00 Bauer, Robert
  2001-06-29  7:10 ` Jean-Christophe Filliatre
  0 siblings, 1 reply; 2+ messages in thread
From: Bauer, Robert @ 2001-06-28 16:00 UTC (permalink / raw)
  To: caml-list

Hi,

I have a little definition below written in ocaml.  My problem is that when
I define the class
lattice_point, I would have liked to specify the types of the parameters;
however, when I do so
I get an error - instead, I have to specify the types of the class's
attributes.  I am hoping that
someone can shed some light on this.

Also, I find that if try to use any capitalized variables, I get interesting
errors - for
example if I try let XYZ_ZYX = (false, false);; I get an error, whereas let
xyz_zyx = (false, false);;
works just fine. Or more simply, let XYZ = (false, false);; fails.  Again, I
am hoping for an explanation.

class lattice_point left right =
 object
  val mutable l:bool = left
  val mutable r:bool = right

  method get_l = l
  method get_r = r
end;;

let top_def = new lattice_point false false;;

Thanks.
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [Caml-list] re: help with ocaml
  2001-06-28 16:00 [Caml-list] re: help with ocaml Bauer, Robert
@ 2001-06-29  7:10 ` Jean-Christophe Filliatre
  0 siblings, 0 replies; 2+ messages in thread
From: Jean-Christophe Filliatre @ 2001-06-29  7:10 UTC (permalink / raw)
  To: Bauer, Robert; +Cc: caml-list


Bauer, Robert writes:
 > 
 > Also, I find that if try to use any capitalized variables, I get interesting
 > errors - for
 > example if I try let XYZ_ZYX = (false, false);; I get an error, whereas let
 > xyz_zyx = (false, false);;
 > works just fine. Or more simply, let XYZ = (false, false);; fails.  Again, I
 > am hoping for an explanation.

Ocaml distinguishes between capitalized and uncapitalized identifiers.
The former are used for  constructors, exceptions and modules, and the
latter for other kinds (values, types, etc.)

This helps  avoiding trivial mistakes,  like mispelling the name  of a
constructor (which  would therefore be  understood as a  variable). It
also  helps  when  reading  third-party  code, since  you  can  easily
discriminate between constructors and functions in an application, for
instance.

There is a page of ocaml reference manual about names:

      http://caml.inria.fr/ocaml/htmlman/manual010.html

Sincerely,
-- 
Jean-Christophe Filliatre
  mailto:Jean-Christophe.Filliatre@lri.fr
  http://www.lri.fr/~filliatr
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs  FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr  Archives: http://caml.inria.fr


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2001-06-29  7:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-06-28 16:00 [Caml-list] re: help with ocaml Bauer, Robert
2001-06-29  7:10 ` Jean-Christophe Filliatre

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).