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 UAA20416; Wed, 27 Aug 2003 20:30:11 +0200 (MET DST) 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 UAA27628 for ; Wed, 27 Aug 2003 20:30:10 +0200 (MET DST) Received: from ep09.kernel.pl (ep09.kernel.pl [212.87.11.162]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h7RIU8f04502 for ; Wed, 27 Aug 2003 20:30:08 +0200 (MET DST) Received: (qmail 30207 invoked by uid 566); 27 Aug 2003 18:30:04 -0000 Date: Wed, 27 Aug 2003 20:27:57 +0200 From: Michal Moskal To: caml-list@inria.fr Cc: Jeff Henrikson Subject: [Caml-list] Re: cyclic modules (was: OCamlMakefile mly/mll interdependency) Message-ID: <20030827182757.GA15479@roke.freak> Mail-Followup-To: caml-list@inria.fr, Jeff Henrikson References: <20030827100125.GA14764@fichte.ai.univie.ac.at> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20030827100125.GA14764@fichte.ai.univie.ac.at> User-Agent: Mutt/1.4.1i X-PGP-Fingerprint: CF89 1B14 11BE 1CC9 2CA3 7497 5E32 69B4 BC71 B4C2 X-AntiVirus: scanned for viruses by AMaViS 0.2.1 (http://amavis.org/) X-Loop: caml-list@inria.fr X-Spam: no; 0.00; michal:01 moskal:01 malekith:01 pld-linux:01 cyclic:01 henrikson:01 frontc:01 recursion:01 cyclic:01 malekith:01 mli:01 val:01 mli:01 val:01 ocamlc:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Wed, Aug 27, 2003 at 12:01:25PM +0200, Markus Mottl wrote: > On Mon, 25 Aug 2003, Jeff Henrikson wrote: > > To help me with the aforementioned release, anybody want to help me > > figure out why my OCamlMakefile isn't doing well on compling frontc? > > No ordering of the source files seems to work: > > This is not really surprising: module Clexer references module Cparser > and vice versa! You cannot have recursion between modules. > > Since the lexer always depends on the parser, because the latter declares > tokens that the lexer returns, the parser must always be compiled before > the lexer. > > Therefore, you'll have to factor out all code from the lexer that is > referenced by the parser and put it into a separate module, which you > have to compile before the parser (and by transitivity before the lexer). Well, I don't know if it's intensional, but OCaml allows one to have cyclic modules if you only use *types*, not values. For example: [malekith@roke t]$ cat a.mli type t = C val f : unit -> bool [malekith@roke t]$ cat a.ml type t = C let f () = B.v [malekith@roke t]$ cat b.mli val v : bool [malekith@roke t]$ cat b.ml let v = (A.C == A.C) [malekith@roke t]$ ocamlc -c a.mli [malekith@roke t]$ ocamlc -c b.mli [malekith@roke t]$ ocamlc -c a.ml [malekith@roke t]$ ocamlc -c b.ml [malekith@roke t]$ ocamlc b.cmo a.cmo [malekith@roke t]$ -- : Michal Moskal :: http://www.kernel.pl/~malekith : GCS {C,UL}++++$ a? !tv : When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h ------------------- 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