caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Yurii A. Rashkovskii" <yrashk@openeas.org>
To: caml-list@inria.fr
Subject: [Caml-list] Namespace proposal
Date: Mon, 12 Aug 2002 17:19:15 +0300	[thread overview]
Message-ID: <02081217191500.26326@rashko.ilt.kharkov.ua> (raw)

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


             reply	other threads:[~2002-08-12 14:16 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-08-12 14:19 Yurii A. Rashkovskii [this message]
2002-08-12 17:31 ` Michael Vanier
2002-08-12 20:40 Yurii A. Rashkovskii
2002-08-15  9:43 Ohad Rodeh
2002-08-15 13:27 ` Vitaly Lugovsky
2002-08-15 14:23   ` Yurii A. Rashkovskii
2002-08-15 15:53     ` Vitaly Lugovsky
2002-08-15 16:21 Gurr, David (MED, self)
2002-08-15 17:00 ` Vitaly Lugovsky
2002-08-18 17:05 ` John Max Skaller
2002-08-15 17:13 Gurr, David (MED, self)
2002-08-15 17:18 ` Vitaly Lugovsky
2002-08-15 17:53   ` Yurii A. Rashkovskii
2002-08-16  8:52   ` M E Leypold @ labnet
2002-08-16  9:22     ` Vitaly Lugovsky
2002-08-16 10:20       ` Yurii A. Rashkovskii
2002-08-15 17:46 ` Fernando Alegre
2002-08-15 20:42 Gurr, David (MED, self)
2002-08-15 20:42 Gurr, David (MED, self)
2002-08-16  9:19 ` Vitaly Lugovsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=02081217191500.26326@rashko.ilt.kharkov.ua \
    --to=yrashk@openeas.org \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).