From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id B9691BC48 for ; Sat, 9 Apr 2005 15:21:35 +0200 (CEST) Received: from smtp2.wanadoo.fr (smtp2.wanadoo.fr [193.252.22.29]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j39DLZE7020504 for ; Sat, 9 Apr 2005 15:21:35 +0200 Received: from me-wanadoo.net (localhost [127.0.0.1]) by mwinf0206.wanadoo.fr (SMTP Server) with ESMTP id 5EFD71C0016A for ; Sat, 9 Apr 2005 15:21:35 +0200 (CEST) Received: from Galois (Mix-Strasbourg-209-4-251.w80-9.abo.wanadoo.fr [80.9.107.251]) by mwinf0206.wanadoo.fr (SMTP Server) with ESMTP id A810E1C00165; Sat, 9 Apr 2005 15:21:34 +0200 (CEST) X-ME-UUID: 20050409132134688.A810E1C00165@mwinf0206.wanadoo.fr Received: from evariste by Galois with local (Exim 4.50) id 1DKFsw-0000sS-4l; Sat, 09 Apr 2005 15:20:26 +0200 Date: Sat, 9 Apr 2005 15:20:26 +0200 From: =?iso-8859-1?Q?S=E9bastien?= Hinderer To: caml-list@yquem.inria.fr, caml-list@inria.fr Subject: Re: Syntactic inclusion of a.ml in b.ml ? Message-ID: <20050409132026.GA3353@galois> Mail-Followup-To: caml-list@yquem.inria.fr, caml-list@inria.fr References: <20050408174142.GA1804@galois> <20050409103532.GA20625@furbychan.cocan.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20050409103532.GA20625@furbychan.cocan.org> X-Miltered: at concorde with ID 4257D6DF.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ens-lyon:01 parsing:01 typedef:01 enum:01 cheers:01 cpp:01 -pp:01 compiler:01 ocaml:01 foo:01 'foo':01 'open:01 -pack:01 ocamlc:01 -pack:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.2 X-Spam-Level: Dear Richard, dear all, > I'm not 100% clear on what you want to do. Sorry, I'll try to be more precise. If I would like to incluee a.ml in b.ml syntactically, it's not to work with small files, but rather, becuse the code in a.ml is automatically generated by a script, by parsing a C source file. The C source code contains something like : typedef enum { A, B, ..., Z } e; The script produces the a.ml file, which contains: | A | B | ... | Z And then I would like to be able to do something like this in b.ml : type t = #include "a.ml" Thans a lot to those who already replied. Cheers, Sébastien. > > A common requirement is to split a large module into a number of > smaller files, which is then compiled back into a single large module. > This can be done using a preprocessor (such as cpp) - see the -pp > option to the compiler. Often it's better just to use a single large > file and a capable editor, with "folding"[1] capabilities. > > Another one is to include the symbols from one module in another. > This can be done using the 'include' directive in OCaml, eg: > > -- a.ml ---- > let foo = 1 > ------------ > > -- b.ml ---- > include A > let bar = 2 > ------------ > > Now, if compiled in the correct order, module B will export symbols > 'foo' and 'bar'. > > 'include' and 'open' are very similar. The difference is that > 'include' causes the symbols imported to be (re-)exported. 'open A' > on the other hand makes the symbols in A available inside B, but they > are not exported in B's interface. > > Another option is to use the -pack argument when linking [not > supported on all platforms]. This causes modules to be nested inside > a "super-module". > > For example, > > ocamlc -pack -o c.cmo a.cmo b.cmo > > (IIRC) creates a module called C containing C.A and C.B modules. > > Rich. > > [1] http://www.moria.de/~michael/fe/folding.html >