Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
From: brogoff <brogoff@speakeasy.net>
To: Brian Hurt <bhurt@spnz.org>
Cc: Erik de Castro Lopo <ocaml-erikd@mega-nerd.com>, caml-list@inria.fr
Subject: Re: [Caml-list] Programming with modules
Date: Fri, 20 Aug 2004 09:56:42 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0408200914581.7889@shell2.speakeasy.net> (raw)
In-Reply-To: <Pine.LNX.4.44.0408200943500.4282-100000@localhost.localdomain>

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


  reply	other threads:[~2004-08-20 16:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-20 11:28 Erik de Castro Lopo
2004-08-20 11:45 ` Richard Jones
2004-08-20 11:59   ` Benjamin Geer
2004-08-20 11:59   ` Erik de Castro Lopo
2004-08-20 12:09     ` Richard Jones
2004-08-27 16:29     ` Richard Jones
2004-08-20 14:47 ` Brian Hurt
2004-08-20 16:56   ` brogoff [this message]
2004-08-21  1:28     ` skaller
2004-08-21  1:57       ` [Caml-list] Programming with classes Jean-Baptiste Rouquier
2004-08-21  2:44         ` skaller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0408200914581.7889@shell2.speakeasy.net \
    --to=brogoff@speakeasy.net \
    --cc=bhurt@spnz.org \
    --cc=caml-list@inria.fr \
    --cc=ocaml-erikd@mega-nerd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox