Browse thread
Re: Some questions about the module system...
- Xavier Leroy
[
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: | Xavier Leroy <xleroy@p...> |
| Subject: | Re: Some questions about the module system... |
> 1) is there any reason (unclear semantics, scope-holing, etc.) why the O'Caml
> module system won't allow an "include <signature>" feature?
Actually, "include <signature>" is available in O'Caml as it was in
Caml Special Light. It was a last-minute addition that never got
documented, but since it causes no harm and seems to be useful, I'll
keep it and document it for the next release.
> b) My second question concerns module coercion by means of module signatures.
> Sharing constraints between module types is really necessary for code
> abstraction, but I found "value aliasing" really useful as well (I don't
> know the exact term for the feature so I will describe it).
The only coercions that can be performed with a signature constraint
(str : sig) are restrictions, i.e. hide components or make their type
info less precise. I doubt renaming of structure components has its
place there. But it's easy (and just as efficient) to do the coercion
yourself, e.g.:
module Node = struct
type node
let less_depth = ...
let less_dist = ...
...
end
module DepthFirstPQueue =
MakePQueue (struct type t = Node.node let leq = Node.less_depth end)
module BestFirstPQueue =
MakePQueue (struct type t = Node.node let leq = Node.less_dist end)
Regards,
- Xavier Leroy