From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 93E48BCAB for ; Thu, 12 May 2005 03:25:05 +0200 (CEST) Received: from pauillac.inria.fr (pauillac.inria.fr [128.93.11.35]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id j4C1P5jH022494 for ; Thu, 12 May 2005 03:25:05 +0200 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 DAA21913 for ; Thu, 12 May 2005 03:25:04 +0200 (MET DST) Received: from kurims.kurims.kyoto-u.ac.jp (kurims.kurims.kyoto-u.ac.jp [130.54.16.1]) by concorde.inria.fr (8.13.0/8.13.0) with ESMTP id j4C1P2gK000797 for ; Thu, 12 May 2005 03:25:03 +0200 Received: from localhost (suiren [130.54.16.25]) by kurims.kurims.kyoto-u.ac.jp (8.13.1/8.13.1) with ESMTP id j4C1Ot3p014404; Thu, 12 May 2005 10:24:56 +0900 (JST) Date: Thu, 12 May 2005 10:24:43 +0900 (JST) Message-Id: <20050512.102443.52652125.garrigue@math.nagoya-u.ac.jp> To: markus.mottl@gmail.com Cc: caml-list@inria.fr Subject: Re: [Caml-list] Renaming structures during inclusions? From: Jacques Garrigue In-Reply-To: References: X-Mailer: Mew version 4.2 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 4282B071.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Miltered: at concorde with ID 4282B06E.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; caml-list:01 pubs:01 semantics:01 markus:01 mottl:01 markus:01 mottl:01 struct:01 struct:01 compiler:01 bindings:01 ocaml:01 imho:01 syntactic:01 structures:01 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on yquem.inria.fr X-Spam-Status: No, score=0.5 required=5.0 tests=INFO_TLD autolearn=disabled version=3.0.2 X-Spam-Level: Well, somebody already worked out a real solution to this problem, at least at the signature level: http://www.eecs.harvard.edu/~nr/pubs/els-abstract.html The point is that once you have solved the signature level problem, you can solve the module level problem: you just have to duplicate your binding under a new name, and hide the old one with a signature where the type is renamed. You could have syntactic sugar for that, but the semantics is clear. So my take on this problem is that the above proposal, or something equivalent, should be included in the language. Jacques Garrigue From: Markus Mottl > I have run into a problem using the "include"-keyword for including > module definitions in other modules. E.g.: > > ---------------------------------------------- > module M1 = struct > type t > module Std = struct end > end > > module M2 = struct > type t > module Std = struct end > end > > module M = struct > include M1 > include M2 > end > ---------------------------------------------- > > The above is not possible, because the names for type t in M1 and M2, > and the module names for module Std clash. Though it would not lead to > any kind of unsoundness to allow this, it would make referring to > shadowed types or modules impossible, both for the user and also for > the compiler in error messages. > > The only solution that seems to make sense and does not impose > excessive work on the user is, IMHO, to provide for a facility to > rename types and modules, e.g. maybe something like: > > ---------------------------------------------- > module M = struct > include M1 > with type t as m1_t > with module Std as M1Std > > include M2 > with type t as m2_t > with module Std as M2Std > > module Std = struct > include M1Std > include M2Std > end > end > ---------------------------------------------- > > In the above example I also added a new Std-module that includes the > contents of the two old ones. > > The only current way to get something similar right now is to > explicitly create new bindings for all entities in the modules to be > included, which may be an enormous amount of work depending on their > size. > > What do the developers think? Would it be a good idea to add a > renaming facility to the language (it wouldn't even require any new > keywords)? > > Best regards, > Markus > > -- > Markus Mottl http://www.ocaml.info markus.mottl@gmail.com