From: Alessandro Baretta <alex@baretta.com> To: climb <onlyclimb@163.com>, Ocaml <caml-list@inria.fr> Subject: [Caml-list] Re: Date: Sun, 20 Oct 2002 22:15:35 +0200 Message-ID: <3DB30EE7.5070202@baretta.com> (raw) In-Reply-To: <20021019171157.AE7A31C5E7580@sm5.163.com> I must advise you to download the O'Reilly caml-book, and read through it. The answers to all your questions are in there. http://caml.inria.fr/oreilly-book/ Alex climb wrote: > i am quite confused about the orgnization of source files. > i have programmed with java . java has a simple rule to orgnize files: one file contains one class(public) or interface, and name of the file and the class must be identical. > > As to Ocaml. > Does the file name of *.ml or mli has some similar relation ship with the content ? > for example , in the on-line manul > it says : > if complie like this > ocaml -c aux.mli > ocaml -c aux.ml > behaves exactly as if > module Aux: sig (* contents of aux.mli*) end = struct (*contents of aux.ml*) end;; > in the toplevel > that seems to imply the exsiting fo some relationship , but i still has these questions: > 1) can many modules be write in just one file ? > maybe not , then how does classes? Yes. Modules can contain modules. Every compilation unit automatically defines a module. An ".mli" defines the signature of the module defined ecapsulating the corresponding ".ml". > 2) Is the multi sigs with one struct or multi structs with one sig compiled at a prper dependency can get the same result that like as in the toplevel? should i write anther file to tell them how to assigning? I don't understand what you mean. > 3) take set.ml and set.mli for example which defined one functor: Make and two sigs : S and OrderedType. But when we use , we use this command Set.Make(..). "Set" here seem can only get from the name of the file. So it seems the file name determined the library name . Then how about the noraml module (not functor) case that if i define a module A with a funtion a(), in file b.ml and b.mli, how can i refer to a() in module A. A.a() or B.A.a() or B.a()? > As I already pointed out, the compiler encapsulates every ".ml" in its own module declaration, where the name of the module is equal to the name of file, with the first letter capitalized. Therefore, if you can write > (* File x.ml *) > > module Abc = struct > let function_of_abc () = ... > end > (* File y.ml *) > > let _ = X.Abc.function_of_abc () Alex ------------------- 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
next prev parent reply index Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-02-23 18:02 francois.hugel 2002-02-23 20:48 ` [Caml-list] Nicolas FRANCOIS (AKA El Bofo) 2002-02-24 12:00 ` stalkern2 2002-06-17 1:04 [Caml-list] Problem with Graph module Nicolas FRANCOIS (AKA El Bofo) 2002-06-17 13:23 ` Jun P.FURUSE 2002-06-17 17:38 ` [Caml-list] Nicolas FRANCOIS (AKA El Bofo) 2002-10-19 17:14 climb 2002-10-20 20:04 ` Alessandro Baretta [this message] 2003-03-08 8:53 Vee Satayamas 2003-03-08 9:06 ` [Caml-list] Seth Kurtzberg 2003-03-10 16:41 ` Brian Hurt 2003-07-24 4:20 [Caml-list] Graphics frustration Matt Gushee 2003-07-26 1:37 ` SooHyoung Oh 2003-07-26 8:58 ` [Caml-list] Nicolas Janin [not found] <200404290855.i3T8sxxM001342@host2.route66.net> 2004-04-29 8:55 ` alex 2004-08-23 20:27 briand 2004-08-24 9:09 ` [Caml-list] Damien Doligez 2011-04-07 14:20 nathalielibertine 2021-04-07 11:51 [Caml-list] Fabien / maufred 2021-04-07 12:50 ` [Caml-list] RE : Jean-Denis EIDEN
Reply instructions: You may reply publically to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=3DB30EE7.5070202@baretta.com \ --to=alex@baretta.com \ --cc=caml-list@inria.fr \ --cc=onlyclimb@163.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
caml-list - the Caml user's mailing list Archives are clonable: git clone --mirror https://inbox.ocaml.org/caml-list AGPL code for this site: git clone https://public-inbox.org/ public-inbox