Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2003-08-27 (18:30)
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 
type t = C
let f () = B.v
[malekith@roke t]$ cat b.mli
val v : bool
[malekith@roke t]$ cat 
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 
[malekith@roke t]$ ocamlc -c
[malekith@roke t]$ ocamlc b.cmo a.cmo
[malekith@roke t]$ 

: Michal Moskal :: : GCS {C,UL}++++$ a? !tv
: When in doubt, use brute force. -- Ken Thompson : {E-,w}-- {b++,e}>+++ h

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: