From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id SAA22319; Sat, 2 Nov 2002 18:22:22 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id SAA21052 for ; Sat, 2 Nov 2002 18:22:21 +0100 (MET) Received: from [192.168.2.24] (as5300.kharkov.ukrtel.net [195.5.1.188]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id gA2HMGD21505 for ; Sat, 2 Nov 2002 18:22:17 +0100 (MET) Received: from yrashk by openeas.org with local (masqmail 0.2.6) id 1881x2-4V2-00; Sat, 02 Nov 2002 19:20:48 +0200 Date: Sat, 2 Nov 2002 19:20:48 +0200 From: "Yurii A. Rashkovskii" To: Alessandro Baretta Cc: caml-list@inria.fr Subject: Re: [Caml-list] module namespace Message-ID: <20021102172048.GD16342@rashko> References: <20021102002456.GC8925@rashko> <3DC39206.5080504@baretta.com> <20021102161015.GB1082@rashko> <3DC3FEA5.3020300@baretta.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="7mxbaLlpDEyR1+x6" Content-Disposition: inline In-Reply-To: <3DC3FEA5.3020300@baretta.com> User-Agent: Mutt/1.4i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk --7mxbaLlpDEyR1+x6 Content-Type: multipart/mixed; boundary="XuV1QlJbYrcVoo+x" Content-Disposition: inline --XuV1QlJbYrcVoo+x Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Hi Alessandro! On Sat, 02 Nov 2002, Alessandro Baretta wrote: > It's not really equivalent. Consider my present work. I have=20 > three ongoing projects: one named afo, one named lib, and=20 > one named vsg. It would be natural to have a means of=20 > identifying my company first, and subsequently identifying=20 > each single project. Your proposal would be to use such=20 > namespace ids as Com.Baretta.VSG, Com.Baretta.Lib and=20 > Com.Baretta.Afo. There's nothing wrong with this, but it is=20 > much less intuitiva and comprehensible than=20 > "http://priv.baretta.com/afo",=20 > "http://priv.baretta.com/lib",=20 > "http://priv.baretta.com/svg". This latter schema allows for=20 > the identification of a URL -- in this case a private one on=20 > an intranet -- associated with the project. Further, such a=20 > schema allows for multiple versions of the same sw -- i.e. a=20 > private alpha such as the above, and a public release -- to=20 > coexist without interfering with each other. Alexander, attached you'll find new version of ocamlns, that=3D20 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/..."=3D20 and so on. =20 > Your schema is viable, and it is good to have your proposal=20 > around. Hopefully, the developers will take a stand on the=20 > issue and propose a standard themselves, in which case it's=20 > likely to resemble what you submitted. Yet, I still advocate=20 > the use of the XML single layered namespace schema as a=20 > simple, flexibile and effective solution. >=20 > Alex >=20 >=20 --=20 Regards, Yurii. --XuV1QlJbYrcVoo+x Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="pa_ns.ml" Content-Transfer-Encoding: quoted-printable (*******************************************************) (* *) (* 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 =3D Grammar.Entry.create gram "mod_ident";; let module_binding =3D Grammar.Entry.create gram "module_binding";; let rename_module =3D ref (fun loc -> <:str_item< open Pervasives >>);; let gen_mod_name l =3D let nsname =3D ref "" in List.iter (fun x -> nsname :=3D !nsname ^ (x ^ "_")) l ;=20 (String.sub !nsname 0 ((String.length !nsname)-1));; let gen_ns_name l =3D let nsname =3D ref "" in List.iter (fun x -> nsname :=3D !nsname ^ (x ^ "_")) l ; !nsname;; let gen_ns_name_s ns =3D let slash s =3D Str.global_replace (Str.regexp "/") "_slash_" s and=20 colon s =3D Str.global_replace (Str.regexp ":") "_colon_" s and=20 amp s =3D Str.global_replace (Str.regexp "&") "_amp_" s and=20 q s =3D Str.global_replace (Str.regexp "?") "_q_" s and=20 qe s =3D Str.global_replace (Str.regexp "=3D") "_eq_" s and=20 p s =3D Str.global_replace (Str.regexp "%") "_p_" s and=20 d s =3D Str.global_replace (Str.regexp "#") "_d_" s and=20 at s =3D Str.global_replace (Str.regexp "@") "_at_" s and dot s =3D Str.global_replace (Str.regexp "\\.") "_dot_" s in (slash (colon (amp (q (qe (p (d (at (dot ns)))))))));;=20 let gen_mod_name_s ns =3D if (String.sub (gen_ns_name_s ns) ((String.length (gen_ns_name_s ns))-1= ) 1) =3D "_" then (String.sub (gen_ns_name_s ns) 0 ((String.length (gen_ns_name_s ns))-1)) else (gen_ns_name_s ns) =20 =20 let gen_module loc mn ns me =3D let name =3D "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ m= n in <:str_item< module $uid:name$ =3D $me$ >> ;; =20 let gen_module_s loc mn ns me =3D let name =3D "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^= mn in <:str_item< module $uid:name$ =3D $me$ >> ;; =20 let gen_module_type loc mn ns mt =3D let name =3D "caml_namespace___" ^ (gen_ns_name ns) ^ "__moduletype___"= ^ mn in <:str_item< module type$uid:name$ =3D $mt$ >> ;; =20 let gen_module_type_s loc mn ns mt =3D let name =3D "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__moduletype__= _" ^ mn in <:str_item< module type$uid:name$ =3D $mt$ >> ;; =20 let gen_module_open loc mn ns =3D let name =3D "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ m= n in rename_module :=3D (fun loc -> <:str_item< module $uid:mn$ =3D $uid:nam= e$>>); =20 <:str_item< open $uid:name$>> ;; =20 let gen_module_open_s loc mn ns =3D let name =3D "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^= mn in rename_module :=3D (fun loc -> <:str_item< module $uid:mn$ =3D $uid:nam= e$>>); =20 <:str_item< open $uid:name$>> ;; =20 let gen_module_use loc ns =3D let name =3D (gen_mod_name ns) in <:str_item< open $uid:name$>> ;; =20 let gen_module_use_s loc ns =3D let name =3D (gen_mod_name_s ns) in <:str_item< open $uid:name$>> ;; =20 let gen_module_open_as loc mn ns asn =3D let name =3D "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ m= n in rename_module :=3D (fun loc -> <:str_item< module $uid:asn$ =3D $uid:na= me$>>); =20 <:str_item< open $uid:name$>> ;; =20 let gen_module_open_as_s loc mn ns asn =3D let name =3D "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^= mn in rename_module :=3D (fun loc -> <:str_item< module $uid:asn$ =3D $uid:na= me$>>); =20 <:str_item< open $uid:name$>> ;; =20 let gen_module_sig loc mn ns mt =3D let name =3D "caml_namespace___" ^ (gen_ns_name ns) ^ "__module___" ^ m= n in <:sig_item< module $uid:name$ : $mt$ >> ;; =20 let gen_module_sig_s loc mn ns mt =3D let name =3D "caml_namespace___" ^ (gen_ns_name_s ns) ^ "__module___" ^= mn in <:sig_item< module $uid:name$ : $mt$ >> ;; =20 EXTEND mod_ident: [ RIGHTA [ i =3D UIDENT -> [i] | i =3D LIDENT -> [i] | i =3D UIDENT; "."; j =3D SELF -> i :: j ] ] ; module_binding: [ RIGHTA [ "("; m =3D UIDENT; ":"; mt =3D module_type; ")"; mb =3D SELF -> <:module_expr< functor ( $m$ : $mt$ ) -> $mb$ >> | ":"; mt =3D module_type; "=3D"; me =3D module_expr -> <:module_expr< ( $me$ : $mt$ ) >> | "=3D"; me =3D module_expr -> <:module_expr< $me$ >> ] ] ; str_item: LEVEL "top" [ [ "module"; i =3D UIDENT; "in" ; ns =3D mod_ident ;=20 me =3D module_binding -> gen_module loc i ns me | "module"; i =3D UIDENT; "in" ; ns =3D STRING ;=20 me =3D module_binding -> gen_module_s loc i ns me | "module";"type"; i =3D UIDENT; "in" ; ns =3D mod_ident ; "=3D"; mt =3D module_type -> gen_module_type loc i ns mt | "module";"type"; i =3D UIDENT; "in" ; ns =3D STRING ; "=3D"; mt =3D module_type -> gen_module_type_s loc i ns mt |=20 "open"; i =3D UIDENT; "in" ; ns =3D mod_ident -> gen_module_open loc i ns ; !rename_module loc |=20 "open"; i =3D UIDENT; "in" ; ns =3D STRING -> gen_module_open_s loc i ns ; !rename_module loc |=20 "open"; i =3D UIDENT; "in" ; ns =3D mod_ident ; "as" ; asn =3D UIDENT = -> gen_module_open_as loc i ns asn; !rename_module loc |=20 "open"; i =3D UIDENT; "in" ; ns =3D STRING ; "as" ; asn =3D UIDENT -> gen_module_open_as_s loc i ns asn; !rename_module loc |=20 "use"; ns =3D mod_ident -> gen_module_use loc ns |=20 "use"; ns =3D STRING -> gen_module_use_s loc ns ] ]; sig_item: LEVEL "top" [ [ "module"; i =3D UIDENT; "in" ; ns =3D mod_ident ; ":" ; mt =3D module= _type -> gen_module_sig loc i ns mt | "module"; i =3D UIDENT; "in" ; ns =3D STRING ; ":" ; mt =3D module_ty= pe -> gen_module_sig_s loc i ns mt ] ]; END ; --XuV1QlJbYrcVoo+x-- --7mxbaLlpDEyR1+x6 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.0 (GNU/Linux) iD8DBQE9xAlv/5/+hDnz2cERAhSJAKDE9S8yanCjYwMU3P8mKrvgeid7KwCggfcp N8Tl14AtOIil7nZn2rleBoE= =Y+ym -----END PGP SIGNATURE----- --7mxbaLlpDEyR1+x6-- ------------------- 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