English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Renaming structures during inclusions?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2005-05-11 (18:02)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] Renaming structures during inclusions?
On 5/11/05, Andreas Rossberg <rossberg@ps.uni-sb.de> wrote:
> Note that OCaml's type system fundamentally relies on the fact that type
> names cannot be shadowed in structures.

Hm, I don't see why this should be so, can you elaborate? I don't know
the compiler internals about type inference, this seems like a
question of how types are identified internally. I make the reasonable
guess that it is not by names (strings) but some kind of integer id or
similar. So "type t type t" could internally still be kept apart,
though producing error messages is a problem (would require printing
of extra tags), and the user could not refer to the shadowed type
anymore. That's why I wouldn't want the compiler to accept this code,
which is the current behaviour anyway.

> While your proposal probably could be made to work in this particular
> case - the compiler had to figure out that it can break the dependency
> on the first t by reordering m1_t relative to the fields from M1 in the
> derived signature and substituting m1_t for t in these fields, likewise
> for the other elements - it is *far* from obvious if and how this can be
> inferred in general, particularly when your modules go higher-order.

Maybe I don't see the problem, but since I feel confident that I can
always solve this problem manually in a fairly mechanized and
straightforward way, I'd be surprised if this couldn't be done by the
compiler. Isn't it just a normal alpha conversion problem? The only
thing that needs to be guaranteed by the compiler is that there is no
name capture, but that, too, isn't difficult to do.


Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com