Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Re: Managing module names
@ 1997-07-24  5:21 Frank Christoph
  1997-07-25 13:56 ` Fabrice Le Fessant
  0 siblings, 1 reply; 7+ messages in thread
From: Frank Christoph @ 1997-07-24  5:21 UTC (permalink / raw)
  To: caml-list

> >>>>> "monniaux" == David Monniaux <monniaux@csl.sri.com> writes:
>     monniaux> Would it be possible to make up some scheme that would to
>     monniaux> things like: /graphics/blackwhite/main ->
>     monniaux> Graphics.Blackwhite.Main ?
> 
>     monniaux> Or, better: would it be interesting according to other users?
> 
> Absolutely! I think that such an arrangement would be even more useful
> than what exists presently.

In my experience, nested modules are not very useful in (O)CAML because you
cannot have a recursive definition cross a module boundary, and I find that
I quite often have mutual dependencies between sets of definitions whose
namespaces I would nevertheless like to separate.

I suspect that the reason package nesting in Java works so well is partly
due to the fact that recursion, etc. is hardly ever used.

On the other hand, SML seems to use module nesting quite freely, though,
and as far as I know it has the same restrictions on module dependencies...

-- FC





^ permalink raw reply	[flat|nested] 7+ messages in thread
* Managing module names
@ 1997-07-22 14:19 Paul Stodghill
  1997-07-22 23:45 ` David Monniaux
  0 siblings, 1 reply; 7+ messages in thread
From: Paul Stodghill @ 1997-07-22 14:19 UTC (permalink / raw)
  To: caml-list

This is the message that I am going to send to Jason, Mark, and the Caml
mailing list. What do you think?

One of the things that modules in O'Caml can be used for is to prevent
namespace pollution. That is, functions and times encapsulated
within modules can be given names without fear that those names will
conflict with names in other modules.

But, how does one prevent pollution in the module namespace?

As near as I can tell, there are two ways to address this problem:

1) Carefully choose the names of the .ml and .mli files that will contain
   each of the top-level modules.

   E.g., Project_util, Project_expr, Project_toplevel

   The advantage of this approach is that each of these modules can go into
   its own source file and each can be compiled seperately. The
   disadvantage is that the module names tend to be longer, or less
   intuitive.

2) Enclose all of the "top-level" modules within a single "Project" module.

   E.g., Project.Util, Project.Expr, Project.Toplevel

   The advantage is that the names of the modules that are visible to the
   user of the Project module are more "rational", and the simpler names of
   the modules can be used simply by openning the Project module. The
   disadvantage seems to be that this requires some contortions in order to
   get this to work:

   Project.mli:
   module Util = Project_util
   module Expr = Project_expr
   module Toplevel = Project_toplevel

   Project_util.ml:
   (* implementation of the Project.Util module *)

   Project_expr.ml:
   (* implementation of Project.Expr module *)
   open Project_expr (* <- Yuck! *)
   ...

Here is my question: Are there other approach that people have used to
managing module name space pollution in O'Caml?

Thanks in advance.
-- 
Paul Stodghill <stodghil@cs.cornell.edu>
http://www.cs.cornell.edu/home/stodghil/home.html





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~1997-07-25 17:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-07-24  5:21 Managing module names Frank Christoph
1997-07-25 13:56 ` Fabrice Le Fessant
1997-07-25 16:39   ` ocamlc compiled in native code Fabrice Le Fessant
  -- strict thread matches above, loose matches on Subject: below --
1997-07-22 14:19 Managing module names Paul Stodghill
1997-07-22 23:45 ` David Monniaux
1997-07-23 12:29   ` Paul Stodghill
1997-07-24 14:36   ` Judicael Courant

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox