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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Brian Hurt <bhurt@s...>
Subject: Re: [Caml-list] Programming with modules
On Fri, 20 Aug 2004, Erik de Castro Lopo wrote:

> Hi all,
> 
> Say I have a module (main.ml) and an interface (main.mli) which
> defines a type maintype.
> 
> However, main.ml is getting a little large and I'd like to split 
> some of the functionality out into another file, but still have
> access to maintype in the new file. Unfortunately, Ocaml doesn't
> allow mutual dependancies across acoss files.
> 
> Does anybody have any suggestions on how to get around this?
> 

Push maintype down the module heirarchy- up to an including creating a 
special module which only contains maintype (and some supporting 
functions), which everything depends upon.

More generally, refactor your code.  Find hunks of code which are already 
mostly independent and consider how to make them more independent, so you 
can cut them out into their own modules.  Limit interactions between 
different parts of the code, and develop interfaces for those interactions 
which are necessary.  This actually leads to more maintainable code.

-- 
"Usenet is like a herd of performing elephants with diarrhea -- massive,
difficult to redirect, awe-inspiring, entertaining, and a source of
mind-boggling amounts of excrement when you least expect it."
                                - Gene Spafford 
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