Subject: Managing module names
From: Paul Stodghill <email@example.com>
Date: 22 Jul 1997 10:19:21 -0400
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
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:
module Util = Project_util
module Expr = Project_expr
module Toplevel = Project_toplevel
(* implementation of the Project.Util module *)
(* 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 <firstname.lastname@example.org> http://www.cs.cornell.edu/home/stodghil/home.html
This archive was generated by hypermail 2b29 : Sun Jan 02 2000 - 11:58:11 MET