From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id RAA28045 for caml-redistribution; Thu, 24 Jul 1997 17:07:12 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id QAA27512 for ; Thu, 24 Jul 1997 16:37:23 +0200 (MET DST) Received: from cri.ens-lyon.fr (cri.ens-lyon.fr [140.77.1.32]) by concorde.inria.fr (8.8.5/8.8.5) with ESMTP id QAA08217 for ; Thu, 24 Jul 1997 16:37:22 +0200 (MET DST) Received: from lip.ens-lyon.fr (lip [140.77.11.11]) by cri.ens-lyon.fr (8.8.5/8.8.1) with ESMTP id QAA06173; Thu, 24 Jul 1997 16:36:57 +0200 (MET DST) Received: from chianti.ens-lyon.fr (chianti [140.77.11.106]) by lip.ens-lyon.fr (8.8.5/8.8.0) with ESMTP id QAA16503; Thu, 24 Jul 1997 16:36:55 +0200 (MET DST) Received: (from jcourant@localhost) by chianti.ens-lyon.fr (8.8.5/8.8.0) id QAA02795; Thu, 24 Jul 1997 16:36:54 +0200 (MET DST) Date: Thu, 24 Jul 1997 16:36:54 +0200 (MET DST) Message-Id: <199707241436.QAA02795@chianti.ens-lyon.fr> From: Judicael Courant To: monniaux@csl.sri.com CC: stodghil@cs.cornell.edu, caml-list@pauillac.inria.fr In-reply-to: <199707222345.QAA07214@tulip.csl.sri.com> (message from David Monniaux on Tue, 22 Jul 1997 16:45:26 -0700 (PDT)) Subject: Re: Managing module names Reply-to: Judicael.Courant@ens-lyon.fr (Judicael Courant) Mime-Version: 1.0 (generated by tm-edit 7.43) Content-Type: text/plain; charset=US-ASCII Sender: weis [Version francaise ci-dessous] > >Concerning the module namespace: >as far as I know, Java uses some mapping of the namespace onto the >filesystem, allowing easy filing of libraries. > >Caml has a hierarchized modules system, but only allows toplevel >modules to be mapped into files. > >Would it be possible to make up some scheme that would to things like: >/graphics/blackwhite/main -> Graphics.Blackwhite.Main ? > I think there is a real problem for dealing with module namespace, but I do not like this solution, because I may have a file /graphics/blackwhite/debug.cmo that I do not always want to open. More generally, I think that the interaction between the language and the filesystem should be kept as small as possible. Rather, I would prefer a small utility (let's say ocamllib) grouping together a bunch of .cmo or .cmi files. For instance assume a.ml contains let x = 1 and b.ml contains let x = A.x then "ocamllib A.cmo B.cmo -o C.cmo" would give the same file C.cmo as the compilation of the following C.ml : module A = struct let x = 1 end module B = struct let x = A.x end Of course, "ocamllib" should also apply in the same way to .cmi files. There is then a clear distinction between the filesystem hierarchy and the language constructs. And if you wish to, you could perfectly add to your makefiles a rule such as %.cmi: % ocamllib $*/*.cmi -o $*.cmi IMHO, this mecanism would be a good replacement for the existing -a option of ocamlc. Also, I guess that implementing ocamllib is much simpler than taking advantage of the filename hierarchy. [English version above] > >[En Francais: pourquoi ne pas profiter du systeme de fichiers pour >rendre plus souple l'usage de la hierarchie de modules?] Il me semble que le besoin d'une gestion plus elabore de la hierarchie des modules est reel, mais je preferais une autre solution, plus independante du systeme de fichier. On pourrait imaginer un utilitaire "ocamllib" capable de grouper des .cmi ou des .cmo. Ainsi, si a.ml contient let x = "quel dommage que le francais ne soit pas la langue internationale !" et b.ml contient let x = A.x alors "ocamllib -o C.cmo A.cmo B.cmo" produirait un fichier C.cmo identique a celui qu'aurait produit la compilation d'un fichier C.ml contenant : module A = struct let x = "quel dommage que le francais ne soit pas la langue internationale !" end module B = struct let x = A.x end Mutatis mutandis pour les .cmi De cette facon, on a une solution assez independante du systeme de fichier employe, probablement plus efficace et plus simple a implanter. Par ailleurs, rien n'empeche d'ecrire dans son Makefile une ligne du type %.cmi: % ocamllib $*/*.cmi -o $*.cmi Judicael. -- Judicael.Courant@ens-lyon.fr, http://www.ens-lyon.fr/~jcourant/ tel : (+33) 04 72 72 85 82 << Heureux ceux qui savent rire d'eux memes : Ils n'ont pas fini de s'amuser ! >>