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 nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id BBFCCD45F for ; Wed, 2 Nov 2005 09:42:03 +0100 (CET) Received: from mail13.bluewin.ch (mail13.bluewin.ch [195.186.18.62]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id jA28g3T0012763 for ; Wed, 2 Nov 2005 09:42:03 +0100 Received: from [10.0.1.2] (81.62.79.11) by mail13.bluewin.ch (Bluewin 7.2.068.1) id 435DFDA20019A13C; Wed, 2 Nov 2005 08:42:00 +0000 In-Reply-To: <875c7e070511011803x598ffb63gd54267aec1fb181e@mail.gmail.com> References: <43679EEF.70102@confluent.org> <875c7e070511011803x598ffb63gd54267aec1fb181e@mail.gmail.com> Mime-Version: 1.0 (Apple Message framework v746.2) Content-Type: text/plain; charset=ISO-8859-1; delsp=yes; format=flowed Message-Id: Cc: Tom Hawkins Content-Transfer-Encoding: quoted-printable From: =?ISO-8859-1?Q?Daniel_B=FCnzli?= Subject: Re: [Caml-list] Nesting Modules Date: Wed, 2 Nov 2005 09:42:04 +0100 To: caml-list@yquem.inria.fr X-Mailer: Apple Mail (2.746.2) X-Miltered: at nez-perce with ID 43687BDB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; epfl:01 caml-list:01 nesting:01 cmo:01 cmi:01 'let:01 ocamlc:01 ocamlc:01 cmo:01 cmi:01 ocaml:01 poses:01 struct:01 usefull:01 struct:01 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.3 e 2 nov. 05 =E0 03:03, Chris King a =E9crit : > One way to do what you're looking to do, is to write in top.ml: > > module Bottom =3D Bottom > > This will essentially re-export Bottom in Top. Unfortunately, this > requires that you link bottom.cmo in with your code, which causes > Bottom to be visible at the top level. It will not be visible to the user if you don't provide bottom.cmi. =20 The problem of linking can be alleviated by packing everything in a =20 cma library. In other words what you can do is > echo 'let f x =3D x' > bottom.ml > echo 'module Bottom =3D Bottom' > top.ml > ocamlc -c bottom.ml > ocamlc -c top.ml > ocamlc -a -o toplib.cma bottom.cmo top.cmo > rm bottom.cmi > ocaml toplib.cma Objective Caml version 3.09.0 # Bottom.f;; Unbound value Bottom.f # Top.Bottom.f;; - : 'a -> 'a =3D When you want to link an executable using Top you now need to specify =20= toplib.cma (instead of top.cmo). Note that using 'include' poses the same problems of visibility and =20 linking so you will have to adopt the same technique. In fact I think =20= that 'module Bottom =3D Bottom' is exactly the same as 'module Bottom =3D = =20 struct include Bottom end', the former being more obvious. 'include' =20 is only usefull if you need to extend the structure with new =20 elements, e.g. 'module Bottom =3D struct include Bottom let g x =3D ... =20= end'. Daniel=