caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Yurii A. Rashkovskii" <yrashk@openeas.org>
To: Alessandro Baretta <alex@baretta.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] module namespace
Date: Sat, 2 Nov 2002 19:20:48 +0200	[thread overview]
Message-ID: <20021102172048.GD16342@rashko> (raw)
In-Reply-To: <3DC3FEA5.3020300@baretta.com>


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

Hi Alessandro!

On Sat, 02 Nov 2002, Alessandro Baretta wrote:

> It's not really equivalent. Consider my present work. I have 
> three ongoing projects: one named afo, one named lib, and 
> one named vsg. It would be natural to have a means of 
> identifying my company first, and subsequently identifying 
> each single project. Your proposal would be to use such 
> namespace ids as Com.Baretta.VSG, Com.Baretta.Lib and 
> Com.Baretta.Afo. There's nothing wrong with this, but it is 
> much less intuitiva and comprehensible than 
> "http://priv.baretta.com/afo", 
> "http://priv.baretta.com/lib", 
> "http://priv.baretta.com/svg". This latter schema allows for 
> the identification of a URL -- in this case a private one on 
> an intranet -- associated with the project. Further, such a 
> schema allows for multiple versions of the same sw -- i.e. a 
> private alpha such as the above, and a public release -- to 
> coexist without interfering with each other.

Alexander, attached you'll find new version of ocamlns, that=20
allows both schemas (mine and yours). I should warn you
that it depends on Str library (str.cma) and theoretically
may not work in some cases. New syntax allows defining:

module A in "http://www.domain.org/..."  ...
open A in "http://www.domain.org/..."=20

and so on.

 
> Your schema is viable, and it is good to have your proposal 
> around. Hopefully, the developers will take a stand on the 
> issue and propose a standard themselves, in which case it's 
> likely to resemble what you submitted. Yet, I still advocate 
> the use of the XML single layered namespace schema as a 
> simple, flexibile and effective solution.
> 
> Alex
> 
> 

-- 
Regards,
Yurii.

[-- Attachment #1.2: pa_ns.ml --]
[-- Type: text/plain, Size: 6610 bytes --]

(*******************************************************)
(*                                                     *)
(* OCamlNS                                             *)
(*                                                     *)
(* Copyright (c) 2001, 2002.                           *)
(* E/AS Software Foundation                            *)
(*                                                     *)
(* Author(s):                                          *)
(*    Yurii A. Rashkovskii                             *)
(*                                                     *)
(* This program is free software; you can redistribute *)
(* it and/or modify it under the terms of the GNU      *)
(* Lesser General Public License as published by the   *)
(* Free Software Foundation; version 2 of the License. *)
(*                                                     *)
(*******************************************************)

open Stdpp;;
open Pcaml;;

let mod_ident = Grammar.Entry.create gram "mod_ident";;
let module_binding = Grammar.Entry.create gram "module_binding";;


let rename_module = ref (fun loc -> <:str_item< open Pervasives >>);;

let gen_mod_name l =
    let nsname = ref "" in
    List.iter (fun x -> nsname := !nsname ^ (x ^ "_")) l ; 
    (String.sub !nsname 0 ((String.length !nsname)-1));;

let gen_ns_name l =
    let nsname = ref "" in
    List.iter (fun x -> nsname := !nsname ^ (x ^ "_")) l ; !nsname;;

let gen_ns_name_s ns =
    let slash s = Str.global_replace (Str.regexp "/") "_slash_" s and 
        colon s = Str.global_replace (Str.regexp ":") "_colon_" s and 
        amp s = Str.global_replace (Str.regexp "&") "_amp_" s and 
        q s = Str.global_replace (Str.regexp "?") "_q_" s and 
        qe s = Str.global_replace (Str.regexp "=") "_eq_" s and 
        p s = Str.global_replace (Str.regexp "%") "_p_" s and 
        d s = Str.global_replace (Str.regexp "#") "_d_" s and 
        at s = Str.global_replace (Str.regexp "@") "_at_" s and
        dot s = Str.global_replace (Str.regexp "\\.") "_dot_" s in
     (slash (colon (amp (q (qe (p (d (at (dot ns)))))))));; 

let gen_mod_name_s ns =
    if (String.sub (gen_ns_name_s ns) ((String.length (gen_ns_name_s ns))-1) 1)
     = "_" then
    (String.sub (gen_ns_name_s ns) 0 ((String.length (gen_ns_name_s ns))-1))
    else (gen_ns_name_s ns)
  
    
let gen_module loc mn ns me =
    let name = "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ mn in
    <:str_item< module $uid:name$ = $me$ >>
;;    

let gen_module_s loc mn ns me =
    let name = "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^ mn in
    <:str_item< module $uid:name$ = $me$ >>
;;    

let gen_module_type loc mn ns mt =
    let name = "caml_namespace___" ^ (gen_ns_name ns) ^ "__moduletype___" ^ mn in
    <:str_item< module type$uid:name$ = $mt$ >>
;;    

let gen_module_type_s loc mn ns mt =
    let name = "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__moduletype___" ^ mn in
    <:str_item< module type$uid:name$ = $mt$ >>
;;    

let gen_module_open loc mn ns =
    let name = "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ mn in
    rename_module := (fun loc -> <:str_item< module $uid:mn$ = $uid:name$>>);    
    <:str_item< open $uid:name$>>
;;    

let gen_module_open_s loc mn ns =
    let name = "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^ mn in
    rename_module := (fun loc -> <:str_item< module $uid:mn$ = $uid:name$>>);    
    <:str_item< open $uid:name$>>
;;    

let gen_module_use loc ns =
    let name = (gen_mod_name ns) in
    <:str_item< open $uid:name$>>
;;    

let gen_module_use_s loc ns =
    let name = (gen_mod_name_s ns) in
    <:str_item< open $uid:name$>>
;;    

let gen_module_open_as loc mn ns asn =
    let name = "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ mn in
    rename_module := (fun loc -> <:str_item< module $uid:asn$ = $uid:name$>>);    
    <:str_item< open $uid:name$>>
;;    

let gen_module_open_as_s loc mn ns asn =
    let name = "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^ mn in
    rename_module := (fun loc -> <:str_item< module $uid:asn$ = $uid:name$>>);    
    <:str_item< open $uid:name$>>
;;    

let gen_module_sig loc mn ns mt =
    let name = "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ mn in
    <:sig_item< module $uid:name$ : $mt$ >>
;;    

let gen_module_sig_s loc mn ns mt =
    let name = "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^ mn in
    <:sig_item< module $uid:name$ : $mt$ >>
;;    

EXTEND

  mod_ident:
    [ RIGHTA
      [ i = UIDENT -> [i]
      | i = LIDENT -> [i]
      | i = UIDENT; "."; j = SELF -> i :: j ] ]
  ;

  module_binding:
    [ RIGHTA
      [ "("; m = UIDENT; ":"; mt = module_type; ")"; mb = SELF ->
          <:module_expr< functor ( $m$ : $mt$ ) -> $mb$ >>
      | ":"; mt = module_type; "="; me = module_expr ->
          <:module_expr< ( $me$ : $mt$ ) >>
      | "="; me = module_expr -> <:module_expr< $me$ >> ] ]
  ;

  str_item: LEVEL "top"
  [
    [ "module"; i = UIDENT; "in" ; ns = mod_ident ; 
       me = module_binding ->
      gen_module loc i ns me
     |
      "module"; i = UIDENT; "in" ; ns = STRING ; 
       me = module_binding ->
      gen_module_s loc i ns me
     |
     "module";"type"; i = UIDENT; "in" ; ns = mod_ident ; "=";
       mt = module_type ->
      gen_module_type loc i ns mt
     |
     "module";"type"; i = UIDENT; "in" ; ns = STRING ; "=";
       mt = module_type ->
      gen_module_type_s loc i ns mt
     | 
     "open"; i = UIDENT; "in" ; ns = mod_ident ->
      gen_module_open loc i ns ; !rename_module loc
     | 
     "open"; i = UIDENT; "in" ; ns = STRING ->
      gen_module_open_s loc i ns ; !rename_module loc
     | 
     "open"; i = UIDENT; "in" ; ns = mod_ident ; "as" ; asn = UIDENT ->
      gen_module_open_as loc i ns asn; !rename_module loc
     | 
     "open"; i = UIDENT; "in" ; ns = STRING ; "as" ; asn = UIDENT ->
      gen_module_open_as_s loc i ns asn; !rename_module loc
     | 
     "use"; ns = mod_ident  ->
      gen_module_use loc ns
     | 
     "use"; ns = STRING  ->
      gen_module_use_s loc ns
    ]

  ];

  sig_item: LEVEL "top"
  [
    [ "module"; i = UIDENT; "in" ; ns = mod_ident ; ":" ; mt = module_type ->
      gen_module_sig loc i ns mt
     |
      "module"; i = UIDENT; "in" ; ns = STRING ; ":" ; mt = module_type ->
      gen_module_sig_s loc i ns mt
    ]

  ];

END
;

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

  parent reply	other threads:[~2002-11-02 17:22 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-02  0:24 Yurii A. Rashkovskii
2002-11-02  8:51 ` Alessandro Baretta
2002-11-02 16:10   ` Yurii A. Rashkovskii
2002-11-02 16:34     ` Alessandro Baretta
2002-11-02 16:57       ` Chris Hecker
2002-11-02 17:20       ` Yurii A. Rashkovskii [this message]
2002-11-02 17:40         ` Alessandro Baretta
2002-11-02 19:14           ` Yurii A. Rashkovskii
2002-11-02 22:37       ` Lauri Alanko
2002-11-04  8:07         ` Alessandro Baretta
2002-11-05 16:27           ` Jeffrey Palmer
2002-11-05 22:30             ` Alessandro Baretta
2002-11-06 10:30             ` Andreas Rossberg
2002-11-06 14:17               ` Yurii A. Rashkovskii
2002-11-06 16:27                 ` Alessandro Baretta
2002-11-06 16:56                   ` Yurii A. Rashkovskii
2002-11-06 19:30                     ` Christian Lindig
2002-11-06 20:36                       ` Alessandro Baretta

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=20021102172048.GD16342@rashko \
    --to=yrashk@openeas.org \
    --cc=alex@baretta.com \
    --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).