From: Paul Stodghill <stodghil@cs.cornell.edu>
To: caml-list@pauillac.inria.fr
Subject: Managing module names
Date: 22 Jul 1997 10:19:21 -0400 [thread overview]
Message-ID: <mld8obtbiu.fsf@mario.cs.cornell.edu> (raw)
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
next reply other threads:[~1997-07-22 16:28 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-07-22 14:19 Paul Stodghill [this message]
1997-07-22 23:45 ` David Monniaux
1997-07-23 12:29 ` Paul Stodghill
1997-07-24 14:36 ` Judicael Courant
1997-07-24 5:21 Frank Christoph
1997-07-25 13:56 ` Fabrice Le Fessant
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=mld8obtbiu.fsf@mario.cs.cornell.edu \
--to=stodghil@cs.cornell.edu \
--cc=caml-list@pauillac.inria.fr \
/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