RE: something akin to Java's "package" in libraries

I vaguely recall a brief discussion of this long ago, but don't see any reference to it on the libraries web page. What I had in mind is something like:
package Graphics.GL module Foo (...) where
import X import Bar.Y import Z ...
where the first conversion is
module-name <- package-name ++ "." ++ module-name
the larger issue would be how to convert imports to qualified imports (and module exports to qualified exports). i think (only my opinion) that something like:
import X
should be qualified to
import Graphics.GL.X as X
unless Graphics.GL.X doesn't exist, in which case it gets defaulted to
import X
This is an interesting suggestion. However, I'd like to see if people really think that writing out the full module names is really a problem in practice - in my (limited) experience with the hierarchical libraries so far I don't mind writing out the full module names in import lists at all, and I even quite like to see the module names written out in full. On the other hand, I haven't been working with any modules that go more than 3 deep in the hierarchy, so I'd like to hear feedback from someone writing a library with multiple modules that lives deep in the hierarchy (Sven - perhaps you qualify with Graphics.Rendering.OpenGL.GL?). But I guess the packages concept helps when you want to graft a subtree of modules from one place in the hierarchy to another, right? I must admit I don't like the idea of defaulting to importing X if <package>.X doesn't exist, I'd prefer the two cases to be syntactically distinct. Perhaps the convention should be that '.X' means '<package>.X', and plain X is left alone. (oh, and there have been various other suggestions along these lines - have a look back through the mailing list archives). Cheers, Simon

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

"Simon Marlow"
On the other hand, I haven't been working with any modules that go more than 3 deep in the hierarchy, so I'd like to hear feedback from someone writing a library with multiple modules that lives deep in the hierarchy (Sven - perhaps you qualify with Graphics.Rendering.OpenGL.GL?).
Then make it wider! The main point of having a hierarchical namespace, is, IMO, to avoid namespace collisions. (You don't need to use Usenet or DNS for a long time to realise that a hierarchy isn't well suited for searching) For all I care, OpenGL might be a top level namespace. :-) -kzm -- If I haven't seen further, it is by standing in the footprints of giants
participants (3)
-
ketil@ii.uib.no
-
Lauri Alanko
-
Simon Marlow