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

Alain Frisch alain.frisch at lexifi.com
Mon Feb 25 21:24:09 GMT 2013


On 2/25/2013 8:13 PM, Xavier Clerc wrote:
> This is no what I mean.
> Packs and namespaces serve two different purposes.
> It just happens that the lack of namespace forced
> people (including me) to use packs as namespaces.

Why forced?  I haven't seen a lot of libraries relying on -pack instead 
of using unique enough module names (but it's true that I don't use a 
lot of third-party libraries).  Using the library name as a common 
prefix for all its modules (and maybe having a module whose name is the 
library name itself in case of libraries with a clear notion of "main 
public module") seems a quite good solution to me and a better one than 
-pack.  Maybe this solution is not so good for libraries whose goal is 
to act as a "standard library" (such as Core), because the intention is 
to create the impression that the library is actually part of the 
language (I don't have the impression to use a library when I write 
String.length or List.map, contrary to when I write Xmlm.make_input); so 
I understand why Jane Street is reluctant to have Core_list.map 
everywhere in their code.  But would it really be a problem to have the 
users write "open Kaputt_abbreviations" instead of "open 
Kaputt.Abbreviations", or Bolt_logger.log instead of Bolt.Logger.log?


Alain


More information about the Platform mailing list