Previous discussions on namespaces?

So far, I know of three proposals to add namespaces to OCaml

  1. Namespaces for OCaml: a proposal
  2. A Proposal for Non-Intrusive Namespaces in OCaml
  3. lpw25/namespaces

My guess is that these have been discussed in some venues (especially the papers) but didn’t make the cut, and there have been other changes which help avoid the naming problem to an extent. Can someone provide links to previous discussions on these proposals?

I’ve looked at Github and this forum but couldn’t find anything relevant. I looked at Mantis and found this ticket which is somewhat relevant but there isn’t a solid discussion on any proposal per se.

To be clear, this post is not meant to stir up a discussion on whether namespaces are a good idea or not or discuss the proposals themselves.

3 Likes

“Other changes which help avoid the naming problem to an extent” are module aliases, namely the special treatment of the module Foo = Bar construct (when Bar is a module path and not something more complex), changed in 4.02 to not introduce a hard dependency on Bar – when the -no-alias-deps flag is active. This lets user manually write “namespace maps” which send short module names to longer conflict-avoiding names. Then -open Foo as a command-line argument was added to avoid having to manually open these namespace maps at the beginning of all the files of your project.

This is described in the following blog post from 2014 (before -open): Better namespaces through module aliases.

There were a lot of discussions about namespaces in 2012. I took the liberty to upload some short proposals that were made at the time by Alain Frisch, Martin Jambon, Nicolas Pouillard and Fabrice Le Fessant. At the time I wrote a synthesis (which drew laughs for being longer than the concatenation of the documents it synthesizes) which was the basis for the specification in your document 1 above (after more discussions with Nicolas Pouillard and Didier Rémy).

3 Likes

I think another thing that took some pressure and urgency off implementing namespaces at the language level was jbuilder (and now Dune)'s built-in support for ‘fake’ namespaces using autogenerated module aliases. We can consider it now as the de-facto standard namespacing mechanism for OCaml.

2 Likes

In previous discussions, I noticed that not everyone has the same expectations from namespaces. Here’s what I personally expect from a namespace feature:

Namespaces should make it easy to

  1. Distribute multiple libraries independently under the same namespace that bears the name of my organization.
  2. Use different versions of a pre-compiled library in the same program.
2 Likes