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 WAA16035; Mon, 17 Feb 2003 22:57:54 +0100 (MET) 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 WAA16092 for ; Mon, 17 Feb 2003 22:57:53 +0100 (MET) Received: from marble.he.net (marble.he.net [216.218.230.2]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h1HLvpf18762 for ; Mon, 17 Feb 2003 22:57:52 +0100 (MET) Received: from ucdavis.edu ([208.227.214.58] (may be forged)) by marble.he.net (8.8.6/8.8.2) with ESMTP id NAA15158 for ; Mon, 17 Feb 2003 13:57:43 -0800 Message-ID: <3E515C22.9080101@ucdavis.edu> Date: Mon, 17 Feb 2003 14:03:14 -0800 From: Issac Trotts User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.1) Gecko/20020913 Debian/1.1-1 MIME-Version: 1.0 To: OCaml List Subject: Re: [Caml-list] mutually dependent modules References: <4.3.2.7.2.20030217102751.0309cb70@localhost> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Chris Hecker wrote: > >> Let's suppose that we have two mutually dependent modules, a.ml and >> b.ml, i.e. in b.ml there is a call like A.f1() and in a.ml there is a >> call like B.f2(). The question is how to link these modules? > > > You can't. Caml doesn't support circular references in modules. > Search the list for lots of threads and in-depth discussion on this topic. > > Chris It's easy to get the desired effect. let print = print_endline module A = struct let rec f1() = (!f2)(); print "A.f1" and f2 = ref(fun () -> ()) end;; module B = struct let f1 = ref(fun () -> ()) let f2 () = print "B.f2" let f3 () = (!f1)() end;; let _ = A.f2 := B.f2 let _ = B.f1 := A.f1 let _ = A.f1() let _ = print "--" let _ = B.f3();; Issac ------------------- 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