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 997C3BB81 for ; Fri, 31 Dec 2004 02:10:38 +0100 (CET) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id iBV1AbqN014693 for ; Fri, 31 Dec 2004 02:10:38 +0100 Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id CAA31221 for ; Fri, 31 Dec 2004 02:10:37 +0100 (MET) Received: from smtp1.adl2.internode.on.net (smtp1.adl2.internode.on.net [203.16.214.181]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id iBV1AZfZ025746 for ; Fri, 31 Dec 2004 02:10:36 +0100 Received: from [192.168.1.200] (ppp194-89.lns1.syd2.internode.on.net [203.122.194.89]) by smtp1.adl2.internode.on.net (8.12.9/8.12.9) with ESMTP id iBV1ALRF037300; Fri, 31 Dec 2004 11:40:23 +1030 (CST) Subject: Re: [Caml-list] recmod From: skaller Reply-To: skaller@users.sourceforge.net To: Anastasia Gornostaeva Cc: caml-list In-Reply-To: <20041230223802.GA54521@ermine.home> References: <20041230223802.GA54521@ermine.home> Content-Type: text/plain Message-Id: <1104455420.29293.66.camel@pelican.wigram> Mime-Version: 1.0 X-Mailer: Ximian Evolution 1.2.2 (1.2.2-4) Date: 31 Dec 2004 12:10:21 +1100 Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 41D4A70D.001 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at nez-perce with ID 41D4A70B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 sourceforge:01 wrote:01 recursion:01 glebe:01 061:98 nsw:01 compile:01 workaround:01 experimental:01 functions:01 modules:01 int:01 int:01 argument:01 X-Spam-Checker-Version: SpamAssassin 3.0.0 (2004-09-13) on yquem.inria.fr X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.0.0 X-Spam-Level: On Fri, 2004-12-31 at 09:38, Anastasia Gornostaeva wrote: > Is it possible to compile such files? > > mod1.ml: > let get a = > if Mod2.mem a then 1 else 2 > > mod2.ml: > let mem a = List.mem a [1;2;3] > let other () = > print_int (Mod1.get 5) > No. There is a new experimental feature which provides some support for intra-module recursion, but at present the modules must reside in the same file. The two common workaround for functions are: (a) pass Mod2.get to Mod1.get as an argument (b) create a reference in mod1.ml initialised to fun (x:int) -> raise Not_found; 1 and in mod2.ml store Mod2.get into it, call it in mod1.ml by first dereferencing it. Another technique is to use classes, which automate the late binding more safely. -- John Skaller, mailto:skaller@users.sf.net voice: 061-2-9660-0850, snail: PO BOX 401 Glebe NSW 2037 Australia Checkout the Felix programming language http://felix.sf.net