[ocaml-platform] on the need and design of OCaml namespaces
Didier Remy
Didier.Remy at inria.fr
Fri Mar 1 13:38:29 GMT 2013
>> The main question whether namespaces are hierarchical or flat is still not
>> answered
>
> I think the question itself assumes that namespaces are a new kind of objects
> (and then we can discuss what is their structure, flat or hierarchical, graph
> with ordered edges, etc). But again, there are some ways to address the needs
> expressed in this discussion without introducing such a notion. In my proposal,
> there is one single "space of names" for modules and compilation units plus a
> feature to control the mapping of module references to compilation units.
Alain,
Yes, your proposal is minimalistic and does not require many changes. And
I've described it as such, I think. So you do not have to keep repeating
this in almost every other message...
However, in order to understand what people need, it is better to leave the
implementation impact aside at this stage. I think the simplicity of your
proposal is orthogonal to the model and has more to do with leaving
namespace manipulation outside of the world.
> In this context, I don't even know how to interpret the question of
> whether namespaces are hierarchical or flat.
But I think it would help to understand each other if you accepted to view
your proposal as a restriction of the hierarchical model, as I think it is
one---or tells us why it does not fit in this model.
Here is my attempt:
It is rather a 2-level model than a flat one, where namespace filenames are
the first level and the content of namespaces are the second level.
- You have a single operation to create namespaces the module alias
construct.
- My understanding is that you would not support auto-open, but you would
allow open commands in namespace files, which was my alternative proposal
to avoid auto-opens.
- Your filename is a list of aliases, which is thus understood as its action
on the current scope rather than as namespace object itself. This way all
operations are ordered.
- I assume you silently allow overriding of names, but I am not sure.
Is this a correct view for you?
Another orthogonal part of your proposal is to have original long unique
names for modules (which looks like a tree like hierarchy, but independent of
namespaces), which seems close to what Fabrice wished (up to whether
canonical names have a tree-like structure or are flat.)
The hierarchical model also requires module to have unique identifiers but
is relative agnostic on how this is achieved. (Gabriel has described several
solutions, but yours is one that fits in the model.)
So, in my current understanding, your proposal is more restrictive, has a
more operational mental model, and mainly leaves the manipulation of
namespaces (creating, merging, etc.) other than an explicit listing out of
the proposal.
Didier
More information about the Platform
mailing list