"Damien Guichard" <alphabl...@orange.fr> writes:

> Hi Dawid,
>
>  
>
> Have you ever considered recursive modules ?
>
> [[http://caml.inria.fr/pub/docs/manual-ocaml/manual021.html#toc75]]

The problem there is that that places everything in one file.

>> The following is what I got when studying OCaml's linking issues:
>> A.mli: val flip : unit - > unit
>> A.ml: let flip () = print_string "1"; B.flop ()  let _ = flip ()
>> B.mli: val flop : unit - > unit
>> B.ml: let flop () = print_string "0"; A.flip ()
>> C.ml: let _ = print_endline "C"

One solution is to use a closure argument to lift dependency out of A
into B:

A.mli: val flip : (unit -> unit) -> unit - > unit
A.ml: let flip flop () = print_string "1"; flop ()
B.mli: val flop : unit - > unit
B.ml: let rec flop () = print_string "0"; A.flip flop ()
C.ml: let _ = print_endline "C"; let _ = A.flip B.flop ()


I had the same problem myself several times and asked why ocaml does
not allow mutually dependencies of modules wheren each ml file only
depends on the other mli file. The reason I was given is
that ocaml does cross module inlining. That means B.ml depends on A.ml
(in its compiled form) for inlining and A.ml depends on B.ml for
inlining. So the dependency is not just on the mli files.

In say C the *.c files only depend on the *.h files and the mutual
dependencies between *.c files are only link time while in ocaml the
cross module inlining makes it a compile time issue.

MfG
        Goswin

_______________________________________________
Caml-list mailing list. Subscription management:
http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
Archives: http://caml.inria.fr
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to