something akin to Java's "package" in libraries

Lauri Alanko la@iki.fi
Sun, 3 Mar 2002 01:37:03 +0200


On Thu, Feb 28, 2002 at 05:22:20PM -0000, Simon Marlow wrote:
> (oh, and there have been various other suggestions along these lines -
> have a look back through the mailing list archives).

Another feature from Java that would be very nice in the module system
is package scope. Currently, if any two modules wish to share bindings,
they have to be entirely public and thus importable by anyone. But a big
library often (practically always) has some common definitions that need
to be shared by many modules in the library, but still are internal to
the library and not meant for public consumption. A package scope would
provide a means to enforce this.

I'm not sure what would be the best practical way to implement this.
Maybe just add another export list:

module Foo.Bar (foo, bar) (baz) where ...

Here the bindings foo and bar would be visible everywhere (where Foo.Bar
was imported) and baz would only be visible in other modules named
Foo.*. And as with ordinary export lists, if a package export list
wasn't declared, it would by default contain _all_ bindings in the
module.

There are probably better ways of doing this, but _some_ kind of a scope
for a multi-module library is definitely needed.


Lauri Alanko
la@iki.fi