From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA14483; Fri, 20 Aug 2004 18:56:46 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA13412 for ; Fri, 20 Aug 2004 18:56:45 +0200 (MET DST) Received: from mail4.speakeasy.net (mail4.speakeasy.net [216.254.0.204]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i7KGuhRM022844 for ; Fri, 20 Aug 2004 18:56:44 +0200 Received: (qmail 5968 invoked from network); 20 Aug 2004 16:56:42 -0000 Received: from shell2.speakeasy.net ([69.17.110.71]) (envelope-sender ) by mail4.speakeasy.net (qmail-ldap-1.03) with AES256-SHA encrypted SMTP for ; 20 Aug 2004 16:56:42 -0000 Date: Fri, 20 Aug 2004 09:56:42 -0700 (PDT) From: brogoff To: Brian Hurt cc: Erik de Castro Lopo , caml-list@inria.fr Subject: Re: [Caml-list] Programming with modules In-Reply-To: Message-ID: References: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Miltered: at concorde with ID 41262D4B.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; brogoff:01 brogoff:01 caml-list:01 mli:01 refactor:01 dependencies:01 cyclic:01 dependencies:01 mixin:01 ocaml:01 hierarchies:01 speakeasy:01 interfaces:01 modules:02 modules:02 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Fri, 20 Aug 2004, Brian Hurt wrote: > 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? > > > 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. This is very good advice, and I believe you'd get the same advice if you were programming in Ada, which also has a module system with (parameterized) modules. In Erik's case, it's the right thing to do. In general, if entities are mutually dependent they belong in the same module. There are a few cases where you really do want to support cross module dependencies, but this seems to be hard to do in a satifactory way. The issue is made worse IMO by the addition of OO, since class hierarchies, at least the ones I've used, tend to have more cyclic dependencies. Whatever became of the mixin approach? -- 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