From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr 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 2334ED45F for ; Wed, 2 Nov 2005 06:44:59 +0100 (CET) Received: from out3.smtp.messagingengine.com (out3.smtp.messagingengine.com [66.111.4.27]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id jA25iwo3030400 for ; Wed, 2 Nov 2005 06:44:58 +0100 Received: from frontend1.internal (mysql-sessions.internal [10.202.2.149]) by frontend1.messagingengine.com (Postfix) with ESMTP id 7A4C6CD7507; Wed, 2 Nov 2005 00:44:56 -0500 (EST) Received: from frontend2.messagingengine.com ([10.202.2.151]) by frontend1.internal (MEProxy); Wed, 02 Nov 2005 00:44:56 -0500 X-Sasl-enc: vgmMlh/59Z6Vp16b21P36BqfpkIyXMGRp03dlNnDzxFp 1130910294 Received: from [172.16.13.150] (burnham.ljcrf.edu [192.231.106.2]) by frontend2.messagingengine.com (Postfix) with ESMTP id 057795703BA; Wed, 2 Nov 2005 00:44:53 -0500 (EST) Date: Tue, 1 Nov 2005 22:43:32 -0800 (PST) From: Martin Jambon X-X-Sender: martin@droopy To: Pietro Abate Cc: caml-list@yquem.inria.fr Subject: Re: [Caml-list] Nesting Modules In-Reply-To: <20051102013936.GA2663@pulp.anu.edu.au> Message-ID: References: <43679EEF.70102@confluent.org> <20051102013936.GA2663@pulp.anu.edu.au> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 4368525A.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 nesting:01 compiler:01 submodule:01 struct:01 numbering:01 pcaml:01 cmo:01 mlast:01 cmo:01 pcaml:01 rec:01 regexps:01 2005,:98 ...:98 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.1 required=5.0 tests=FORGED_RCVD_HELO autolearn=disabled version=3.0.3 On Wed, 2 Nov 2005, Pietro Abate wrote: > On Tue, Nov 01, 2005 at 10:59:27AM -0600, Tom Hawkins wrote: >> Can I instruct the compiler to nest Bottom somewhere in Top, to obtain >> clean, hierarchical names (eg: Top.Bottom.some_function)? Of course I >> can inline bottom.ml in top.ml, but then the file become rather large. > > There should be some way in camlp4 to inline files with and > #include "file.ml" directive... Or at least I've a vague memory > of this... I remember of a thread on this ml a while ago but I never > use this trick. Does anybody can confirm this ? Some time ago I wrote some code which works partially. You can include a file from within a submodule, i.e. you can do this: module A = struct USE "module_a.ml" end The problem is line numbering. Setting Pcaml.input_file doesn't seem to have any effect. If anyone knows how to fix that please let me know: (* camlp4o pa_extend.cmo q_MLast.cmo -loc loc pa_use.ml *) let parse_stream s = let f = !Pcaml.parse_implem in let rec loop () = match f s with l, true -> List.map fst l @ loop () | l, false -> List.map fst l in loop () let parse_file file = let ic = open_in file in let stream = Stream.of_channel ic in let current_file = !Pcaml.input_file in Pcaml.input_file := file; (* it doesn't work *) let l = parse_stream stream in close_in ic; Pcaml.input_file := current_file; l EXTEND Pcaml.str_item: [ [ "USE"; file = STRING -> let l = parse_file file in <:str_item< declare $list:l$ end >> ] ]; END (********************************) Martin -- Martin Jambon, PhD http://martin.jambon.free.fr Freedom for the regexps! http://martin.jambon.free.fr/micmatch-howto.html