Browse thread
Renaming structures during inclusions?
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Markus Mottl <markus.mottl@g...> |
| Subject: | Renaming structures during inclusions? |
Hi,
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