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

Sylvain Le Gall sylvain+ocaml at le-gall.net
Fri Feb 22 09:31:20 GMT 2013


2013/2/22 Xavier Clerc <xavier.clerc at inria.fr>:
> ----- Mail original -----
>> On Thu, Feb 21, 2013 at 07:23:19PM +0100, Alain Frisch wrote:
>> > What would be the justification for hierarchical names?
>>
>> One of the advantages that comes to mind is the ability to piggyback
>> on
>> already existing, world-wide, unambiguous, hierarchical namespaces
>> out
>> there, such as DNS. It's overly verbose, but if you dream of a very
>> widespread adoption of the language (a-la Java), then namespaces like
>> org.apache.... have their advantages in terms of scalability.
>
> I concur. However, I would like to draw your attention on the fact that
> hierarchical names tend to convey the intuition that the parent element
> somehow "contains" the children elements. In Java, this is an incorrect
> assumption, as the namespace is indeed flat. My bet is that if hierarchical
> names are used, it has to be reflected in the semantics.
>
>
> More generally on the subject of namespaces, shouldn't we assess the
> merits and mistakes of their equivalents in other languages?
>

I tend to agree with Alain about the fact that hierarchical namespaces
is overkill. Flat namespace is easier to achieve and will solve most
problems.

Working with Java all days long and its namespace, I would say it is
totally useless to copy that! What the meaning of org.apache? Will I
have to name my libraries net.le-gall.sylvain.Foo or
org.ocamlcore.forge.ounit.OUnit?

Honestly, hierarchical namespace just makes mandatory IDE completion
(read Eclipse or IntelliJ here). And even in this case the
autocomplete boxes are too small to make the difference between
org.apache.utils.String and org.apache.bar.utils.String.

If we have to vote on this topic, I would say: flat namespace and
that's enough for me.

Regards
Sylvain


More information about the Platform mailing list