caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* About namespaces
@ 2008-11-20 21:29 David Rajchenbach-Teller
  2008-11-20 21:57 ` [Caml-list] " Christophe Raffalli
  2008-11-22 19:30 ` Ashish Agarwal
  0 siblings, 2 replies; 4+ messages in thread
From: David Rajchenbach-Teller @ 2008-11-20 21:29 UTC (permalink / raw)
  To: Caml

At the moment, there is no difference between modules and namespaces.
Among other things, this means that if I write an extension MyList to
List and someone else writes and extension HisList to List, there is no
automated way to merge these, I need to write yet another module
LatestList to be able to use both extensions at the same time. While
this is certainly possible, it's also quite clumsy and prevents drop-in
additions to existing modules (or hierarchies, yes) by third-party
libraries, something which, as Richard Jones points out, may be
important.

All of this is due to the fact that modules are closed: once a module
has been written, there is no way to add something to that module
without altering the source code or writing a new module.

Now, David Allsopp suggested (off-list) that we could perhaps implement
namespaces as a Camlp4 extension, with the use of external configuration
files (something which can already be managed with findlib). I'm
shamelessly forwarding his idea and asking for feedback.

Where we have [open List] to open one specific module called [List], we
could introduce
* [use List] to open all the modules registered as providing namespace
[List]
* [import List] to locally rebind [List] to a module obtained by
including all the modules registered as providing namespace [List]

In each case, finding out which modules are registered as providing
namespace [List] is performed statically, by Camlp4 reading a set of
external configuration files.

What do you think?

Cheers,
 David
-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings liquidations. 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] About namespaces
  2008-11-20 21:29 About namespaces David Rajchenbach-Teller
@ 2008-11-20 21:57 ` Christophe Raffalli
  2008-11-21  9:24   ` David Rajchenbach-Teller
  2008-11-22 19:30 ` Ashish Agarwal
  1 sibling, 1 reply; 4+ messages in thread
From: Christophe Raffalli @ 2008-11-20 21:57 UTC (permalink / raw)
  To: David Rajchenbach-Teller; +Cc: Caml


[-- Attachment #1.1: Type: text/plain, Size: 923 bytes --]

And what about include (it is your import) ? It allows what you want and
is short ?


module Mylist = struct
  let id x = x
end

module Hislist = struct
  let id2 x = x
end

module Alllist = struct
  include Mylist
  include Hislist
end

What is really missing is renaming when opening or doing include (with
regular expression pattern matching for instance).

Cheers,
Christophe


-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution 
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------


[-- Attachment #1.2: Christophe_Raffalli.vcf --]
[-- Type: text/x-vcard, Size: 310 bytes --]

begin:vcard
fn:Christophe Raffalli
n:Raffalli;Christophe
org:LAMA (UMR 5127)
email;internet:christophe.raffalli@univ-savoie.fr
title;quoted-printable:Ma=C3=AEtre de conf=C3=A9rences
tel;work:+33 4 79 75 81 03
note:http://www.lama.univ-savoie.fr/~raffalli
x-mozilla-html:TRUE
version:2.1
end:vcard


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 249 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] About namespaces
  2008-11-20 21:57 ` [Caml-list] " Christophe Raffalli
@ 2008-11-21  9:24   ` David Rajchenbach-Teller
  0 siblings, 0 replies; 4+ messages in thread
From: David Rajchenbach-Teller @ 2008-11-21  9:24 UTC (permalink / raw)
  To: Christophe Raffalli; +Cc: Caml

On Thu, 2008-11-20 at 22:57 +0100, Christophe Raffalli wrote:
> And what about include (it is your import) ? It allows what you want and
> is short ?

No, [include] is the low-level mechanism which must be used to implement
the higher-level [import]. The main difference being that [import] needs
to read information from all the (findlib) packages which are being used
to compile your project and determine all the modules from each package
which are registered as providing [List]. The programmer doesn't need to
know the exact name of each module.

Does that make things any clearer?

Cheers,
 David


-- 
David Teller-Rajchenbach
 Security of Distributed Systems
  http://www.univ-orleans.fr/lifo/Members/David.Teller
 Angry researcher: French Universities need reforms, but the LRU act brings liquidations. 


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Caml-list] About namespaces
  2008-11-20 21:29 About namespaces David Rajchenbach-Teller
  2008-11-20 21:57 ` [Caml-list] " Christophe Raffalli
@ 2008-11-22 19:30 ` Ashish Agarwal
  1 sibling, 0 replies; 4+ messages in thread
From: Ashish Agarwal @ 2008-11-22 19:30 UTC (permalink / raw)
  To: Caml List

[-- Attachment #1: Type: text/plain, Size: 493 bytes --]

> Among other things, this means that if I write an extension MyList to
> List and someone else writes and extension HisList to List, there is no
> automated way to merge these, I need to write yet another module
> LatestList to be able to use both extensions at the same time.


Merging these with the import command you propose requires an external
configuration. Would that be any easier than using include to define a new
module? Or is there supposed to be some other benefit I'm missing?

[-- Attachment #2: Type: text/html, Size: 710 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2008-11-22 19:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-11-20 21:29 About namespaces David Rajchenbach-Teller
2008-11-20 21:57 ` [Caml-list] " Christophe Raffalli
2008-11-21  9:24   ` David Rajchenbach-Teller
2008-11-22 19:30 ` Ashish Agarwal

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).