Re: Some questions about the module system...

Xavier Leroy (xleroy@pauillac.inria.fr)
Wed, 24 Jul 1996 11:15:50 +0200 (MET DST)

From: Xavier Leroy <xleroy@pauillac.inria.fr>
Message-Id: <199607240915.LAA22240@pauillac.inria.fr>
Subject: Re: Some questions about the module system...
To: fva@ing.uc3m.es
Date: Wed, 24 Jul 1996 11:15:50 +0200 (MET DST)
In-Reply-To: <9607221531.AA06681@elrond.uc3m.es> from "Francisco J. Valverde" at Jul 22, 96 05:19:49 pm

> 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