caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jacques Garrigue <garrigue@math.nagoya-u.ac.jp>
To: markus.mottl@gmail.com
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] Renaming structures during inclusions?
Date: Thu, 12 May 2005 10:24:43 +0900 (JST)	[thread overview]
Message-ID: <20050512.102443.52652125.garrigue@math.nagoya-u.ac.jp> (raw)
In-Reply-To: <f8560b80505110844611fcfbd@mail.gmail.com>

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 <markus.mottl@gmail.com>

> 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


  parent reply	other threads:[~2005-05-12  1:25 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-11 15:44 Markus Mottl
2005-05-11 16:33 ` [Caml-list] " Christophe TROESTLER
2005-05-11 17:11   ` Andreas Rossberg
2005-05-11 18:02     ` Markus Mottl
2005-05-12 14:24       ` Andreas Rossberg
2005-05-11 18:16     ` Christophe TROESTLER
2005-05-12  1:24 ` Jacques Garrigue [this message]
     [not found]   ` <f8560b80505120836681ab281@mail.gmail.com>
2005-05-12 17:09     ` Markus Mottl
2005-05-12 15:26 ` Norman Ramsey
2005-05-12 20:02 ` Aleksey Nogin

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=20050512.102443.52652125.garrigue@math.nagoya-u.ac.jp \
    --to=garrigue@math.nagoya-u.ac.jp \
    --cc=caml-list@inria.fr \
    --cc=markus.mottl@gmail.com \
    /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).