Version française
Home     About     Download     Resources     Contact us    
Browse thread
[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: Yurii A. Rashkovskii <yrashk@o...>
Subject: [Caml-list] Namespace proposal
Hi,

I'd like to submit a proposal for OCaml namespaces. Any questions, reports 
about my mistakes and so on are welcome :)



OCaml Namespace Proposal
========================

Version: 0.1 (DRAFT)

1. What Is a Namespace?
=======================

Namespace is an approach to assemble all components used for development
in way that will prevent name coincidence.

2. Syntax
=========

Namespace support will add new reserved keyword 'namespace' that will be
used in way indentical to 'module', except that namespaces could not be
parametrized (no polymorphism allowed). Namespace will not be module
replacement.

Example:

namespace Org = struct

   namespace Openeas = struct

      namespace Core = struct
 
        ...

      end

   end

end


The above example creates Org, Org.Openeas and Org.Openeas.Core namespaces.


4. How It Works?
================

To solve the positing problem (preventing name coincidence) namespaces
are subject to be "glued". This means that in case of coincidence of names
namespaces' signatures and structures are glued in two new single one 
signature and structure.

Example:

namespace Org = struct

   namespace Openeas = struct

      namespace Core = struct

         let f x = x

      end

   end

end


namespace Org = struct

   namespace Openeas = struct

      namespace Misc = struct

         let j x = x

      end

   end

end


The above example will define namespaces Org.Openeas.Core and Org.Openeas.Misc
with some functions inside. There we'll get the first benefit - we could 
define
namespaces absolutely independing with coincident names and this will make no
harm for the development.

The next benefit is that we could add functions and objects to existing 
namespace 
wherever.

Since OCaml is a language that pretends to be fully adopted for the "real 
world"
programming, namespaces will add the possibility to construct applications in 
a
more clean way.


5. Some Considerations
======================

In order to make namespaces' implementation easier it is proposed to "glue" 
namespace
structures and signatures only on opening modules that contain namespace(s).

So, for instance, we have module HTTP_Library that contains Org.W3.HTTP 
namespace defined and module FTP_Library that contains 
Net.Sourceforge.CamlFtp namespace defined.

(* Here is no Org.W3.HTTP namespace *)

open HTTP_Library;;

(* Here Org.W3.HTTP namespace is available *)
(* but no Net.Sourceforge.CamlFtp *)

open FTP_Library;;

(* And here Net.Sourceforge.CamlFtp is available *)

-- 
Regards,
Yurii
-------------------
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