Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] Circular module dependencies
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: brogoff <brogoff@s...>
Subject: Re: [Caml-list] Circular module dependencies
On Tue, 7 Sep 2004, Tony Edgin wrote:

> Hi all.
>
> Recently, there was a thread which talked about how difficult module
> dependencies were to resolve for linking in Ocaml.  I'm guessing this is
> because of cycles in the dependency graph.
>
> My thought is that maybe Ocaml shouldn't allow this to happen.  Wouldn't
> cyclical module dependencies be a symptom of bad design?  If a cyclic
> dependency occurs I can think of two ways of removing.
>
> First, if the dependency is among modules which are closely related, the code
> in each module in the cycle which interacts, should be extracted into its own
> module.   The cycle indicates code which is semantically related and would
> probably be easier to understand if it were all contained in the same file
> anyway.

In a discussion on this topic a while back, Fergus Henderson cited as an
example the Mercury compiler, where removing the dependencies by making one
big file of the dependent parts would lead to a pretty large file. I thought
that was a decent argument in favor of allowing mutually recursive functions
to cross module boundaries.

Another good example is when you have programs written in functorized style
(eg the Set module in OCaml) and you want to define a type which is in a
recursive relationship with the functor instantiation.

There are workarounds for those cases, but I think it's fair to say that
the desire for some recursive module capability is not always on account of
bad design.

-- Brian

-------------------
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