caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Michal Moskal <malekith@pld-linux.org>
To: caml-list@inria.fr
Cc: Jeff Henrikson <jehenrik@yahoo.com>
Subject: [Caml-list] Re: cyclic modules (was: OCamlMakefile mly/mll interdependency)
Date: Wed, 27 Aug 2003 20:27:57 +0200	[thread overview]
Message-ID: <20030827182757.GA15479@roke.freak> (raw)
In-Reply-To: <20030827100125.GA14764@fichte.ai.univie.ac.at>

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


  reply	other threads:[~2003-08-27 18:30 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-08-26  0:40 [Caml-list] OCamlMakefile mly/mll interdependency Jeff Henrikson
2003-08-27 10:01 ` Markus Mottl
2003-08-27 18:27   ` Michal Moskal [this message]
2003-08-27 18:53     ` [Caml-list] Re: cyclic modules (was: OCamlMakefile mly/mll interdependency) Ville-Pertti Keinonen
2003-08-27 19:03       ` Ville-Pertti Keinonen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030827182757.GA15479@roke.freak \
    --to=malekith@pld-linux.org \
    --cc=caml-list@inria.fr \
    --cc=jehenrik@yahoo.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).