[erlang-questions] Package Support/Use

Richard A. O'Keefe <>
Thu Nov 2 02:40:06 CET 2006

"Eric Merritt" <> praised packages:
	Package names offer a well understood and well tested solution
	to this problem.  They are even in the language right now, but
	their unsupported (going away any time) status makes them
Package names may be well understood, but one of the things we understand
about them is that they are wrong, as in "inside-out, back-to-front, and
going away from you on the other side" (Goon Show quote).

What do I mean?

Let's take a tiny example where we have a "master" module 'arnold'
and some supporting modules 'betty' and 'cody'.  What we really want
to do is to wrap them up somehow and expose onle 'arnold':

    -module(arnold, "src/arnold.erl").
    -module(betty,  "src/betty.erl").
    -module(cody,   "src/cody.erl").
    -export(arnold, [start/0,serve/1,stop/0]).

>From the outside, this flotilla looks like a single module exporting
some functions.  On the inside, arnold, betty, and cody can refer to
each other directly by simple names.  They can also refer to "pervasive"
modules from Erlang/OTP by simple names.

What happens if we use Java-style package names?

First, we have to choose a single GLOBALLY usable package name.
For example, I might have to use


and now the modules have to refer to each other by these complex names.
They don't have to mention these names repeatedly (given the preprocessor,
that's obvious), but they do have to mention the prefix at least once.

Now we have a maintenance problem and a forgery problem.

The forgery problem is that nothing actually stops anyone using any
module name they like.  There is no REAL difference between
nz.ac.otago.cs.ok.arnold and nz_ac_otago_cs_ok_arnold; one uses dots
and the other uses underscores.  Big deal.  Someone else decides to
use nz.ac.otago.cs.ok for some modules?  Just what is there to stop
them?  There is NOTHING that can stop someone reusing one of my dotted
module names for something else.  Just as any Erlang programmer anywhere
can use nz_ac_otago_cs_ok_arnold, so any Erlang programmer anywhere can
use nz.ac.otago.cs.ok.arnold.

The maintenance problem is that if I want to copy some modules into
another package, I have to hunt down and rename all the dotted names.
Of course that's true with underscore prefixes as well; the point is
that dotted names fail to provide any advantage here.

Basically, there are three kinds of module names we want to use:

    - module names in our own application/flotilla/cluster.

      These names need to be RELATIVE, so that the entire thing can
      be moved around with at most one change in one file.

    - names for modules provided by Erlang/OTP itself.

      These names are very common and need to be short, but we don't
      want new names added here to conflict with our own names.

    - names for other applications/flotillas/clusters.

      For these we typically need some kind of ABSOLUTE name.

The problem with the present Erlang language is that there is a single
global name space for modules.  The fundamental problem with package names
is that they don't change that:  there is still a single global name space
for modules, except now module names can contain dots as well as underscores.
Big deal.

No, what we need to do is to reify module name spaces and allow more than
one of them.  They should be actual run time data structures that can be

More information about the erlang-questions mailing list