module namespaces
Johannes Waldmann
joe@isun.informatik.uni-leipzig.de
Wed, 28 Feb 2001 11:17:22 +0100 (MET)
I think the namespace proposal wants to be strictly upward compatible,
therefore it's perhaps not the right time to discuss this ...
but still I think the question "why should the source text of a module
contain its name?" wants an answer.
Even if we stick to module headers, I don't really like the idea of
`module Fully.Qualified.Name where ..'
The proposal mentions the analogy to Java.
My knowledge of that is minimal, but in Java,
they have `package Foo.Bar.Frobs' (full name required)
and `class Frobble' (only last name there).
So, a Haskell module corresponds to what?
I understand the argument "the compiler needs to generate unique names
in the object files" but this is a matter of implementation,
about which the programmer (at least theoretically) should not care.
I think the underlying design decision here is:
how far should the user of a set of modules expect
that he can move their source/interface/object files around,
and still compile them/link against them correctly.
The present proposal seems to imply: not at all.
This is a conservative answer. It is easy to implement,
and guarantees some consistency. Is it too restrictive?
But assume this policy is adopted. Then I am not allowed
to move (precompiled) modules around physically.
That's why I want some means of renaming them (during importing),
and as I wrote earlier, not only for single modules (`import Foo as Bar')
but also for complete hierarchies (`import Leipzig.Standard as Standard')
A potential problem is that the root of some hierarchy
perhaps is just a directory (that contains subdirs and modules)
but not itself a module. One would need to write a dummy module
that just (qualified-)imports and re-exports all submodules.
But this had to be extended whenever a submodule is added.
This doesn't feel right. (On the other hand, the libFoo.a file
had to be rebuilt anyway on such an occasion.)
This leads to another question - during the linking stage:
when should the compilation manager look for a single object file,
and when should it expect an archive?
Anyway I think even the most restricitve form of hierarchical module names
would be very helpful. I certainly would start using it.
--
-- Johannes Waldmann ---- http://www.informatik.uni-leipzig.de/~joe/ --
-- joe@informatik.uni-leipzig.de -- phone/fax (+49) 341 9732 204/252 --