Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
RE: [Caml-list] Namespace proposal
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alessandro Baretta <alex@b...>
Subject: Re: [Caml-list] Namespace proposal: XML variant
I thoroughly dislike any "package ~= directory" solution, 
yet I think a namespace construct should be present in the 
language in order to allow interoperability between 
different projects with different naming conventions. I 
propose a scheme à la XML, where namespaces are URIs 
belonging to the person or organization which releases the 
associated code.

I propose to add an optional namespace construct to 
explicitly associate namespace URIs with namespace names.

namespace MyBigProject = ""

module Foobar in MyBigProject = ...

When I want to use somebody else's code I code just define a 
namespace name. Consider, for example, that I need to use 
Pxp in my project. Nowadays, I'd have to write

open Pxp_document
open Pxp_yacc

With my scheme I'd write

namespace Pxp = 
(* or whatever URI Gerd might choose. *)

open Document in Pxp;
open Yacc in Pxp;
(* Assuming Gerd would adopt this namespace scheme *)

This is very very similar to the approach taken by XML. I 
think this is the model we should refer to when discussing a 
namespace scheme for OCaml. This technique only serves the 
purpose of avoiding name clashes between modules: every 
module name lives within the namespace belonging to and 
defined by the author. No assumptions are made w/respect to 
directory structure. Yet, the build evironment, with some 
help from such a program as ocamldep, could extract 
information from the namespace URIs and use it as a hint for 
source file search. Yet, harnessing URI for the sake of 
filename resolution would be entirely optional and delegated 
to the build environment.

I hope to get some feedback on this proposal. What do you 
guys think about it?


To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: