[ocaml-platform] on the need and design of OCaml namespaces

Alain Frisch alain at frisch.fr
Thu Feb 21 18:03:01 GMT 2013


On 2/21/2013 4:36 PM, Leo White wrote:
> As I see it what we *need* from namespaces is fairly simple:
>
>   Developers must be able to give their components long (hierarchical)
>   names without changing the component's filename.
>
> This allows components with the same filename to coexist within the
> search path. It also allows these components to be grouped together
> without packing them into a single module.

What would be the justification for hierarchical names?  It seems that a 
flat qualifier is enough to support the two goals you mention (making 
components with the same filename coexist, and grouping them with a 
common name).  In practice, we will have a namespace per distributed 
library (e.g. Core, Extlib, Xml-light, ...).  Restricting to flat 
qualifiers might enable a simpler design.

Personally, I'm not even convinced of the need for supporting several 
compilation units with the same filename.  Basically, we will encode 
namespace information inside the .cmi instead of doing it in the 
filename, forcing the compiler to open files only to discover they are 
not in the correct namespace.  Is it really so tedious to use longer 
filenames?  For the library developer, I'd say no.  For the library 
user, maybe, and I'd rather focus on providing ways to make it simpler 
to refer to long module names, such as a good module alias feature in 
the language and/or a way to customize the link between names in source 
files and external module names (a mapping could be specified in 
external files).


Alain


More information about the Platform mailing list