English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2004-09-06 (21:19)
From: Tony Edgin <edgin@s...>
Subject: [Caml-list] Circular module dependencies
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 

Second, if the cycle contains modules which aren't closely related, a new 
module should be created to encapsulate this dependency.  This could be done 
using the Bridge pattern.  Since mutual dependencies make code brittle, 
explicitly revealing the cycle in a module makes the cycle more visible to 
the programmers and thus easier to deal with safely.

Are there any examples of cyclic dependencies which shouldn't be handled by 
either of these cases?

Tony Edgin

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