From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA21011; Sun, 20 Oct 2002 22:04:49 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA20819 for ; Sun, 20 Oct 2002 22:04:47 +0200 (MET DST) X-SPAM-Warning: Sending machine is listed in blackholes.five-ten-sg.com Received: from athlon.baretta.com (host236-68.pool80116.interbusiness.it [80.116.68.236]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9KK4k507826 for ; Sun, 20 Oct 2002 22:04:46 +0200 (MET DST) Received: from baretta.com (localhost.localdomain [127.0.0.1]) by athlon.baretta.com (Postfix) with ESMTP id 7A2FA2724D; Sun, 20 Oct 2002 22:15:35 +0200 (CEST) Message-ID: <3DB30EE7.5070202@baretta.com> Date: Sun, 20 Oct 2002 22:15:35 +0200 From: Alessandro Baretta Organization: Baretta srl -- www.baretta.com User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020826 X-Accept-Language: it, en MIME-Version: 1.0 To: climb , Ocaml Subject: [Caml-list] Re: References: <20021019171157.AE7A31C5E7580@sm5.163.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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