Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] OCamlMakefile mly/mll interdependency
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michal Moskal <malekith@p...>
Subject: [Caml-list] Re: cyclic modules (was: OCamlMakefile mly/mll interdependency)
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