English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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: 2002-08-30 (17:54)
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 = "http://alexbaretta.com/big_project/"

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 caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners