Q: Q: Module system and separate compilatioQ:

Jocelyn Serot (Jocelyn.Serot@lasmea.univ-bpclermont.fr)
Thu, 21 Mar 1996 13:10:16 MET

Message-Id: <199603211208.NAA07231@concorde.inria.fr>
From: Jocelyn Serot <Jocelyn.Serot@lasmea.univ-bpclermont.fr>
Subject: Q: Q: Module system and separate compilatioQ:
To: caml-list@margaux.inria.fr
Date: Thu, 21 Mar 1996 13:10:16 MET

Hello,

First of all, thanks to W. Lux and C. Boos for their clever answers to my last
questions about the interaction between the module system and the file system.
What i had not realized - it seems - is that the module language is
_implicitely_ spoken within the file system and that functor application
takes place automatically during the linking phase.

There seems to be a situation where _explicit_ functor application
is useful: when you have defined two distincts implementation for module
Foo (both matching the signature defined in foo.mli).

With the "all in same file, with explicit module declaration" approach , you
can write:

module type Bar = sig ... end

module type Foo = sig ... end

module Foo1 : Foo = struct ... (* 1st impl *) ... end

module Foo2 : Foo = struct ... (* Another impl *) ... end

module MakeBar(M: Foo) = (struct ... let double = ... Foo.add ... end : Bar)

and then _choose_ to build a Bar implementation using either Foo1

module Bar = MakeBar(Foo1)

or Foo2

module Bar = MakeBar(Foo2)

How can you translate the same approach with the signatures and implementations
for Foo and Bar being in distinct files (that is: foo.mli, foo1.ml, foo2.ml,
bar.mli and bar.ml) ?
It seems that you have to copy foo.mli to foo1.mli and foo2.mli to express
that these implementations both match the signature required by Bar.
But then, you have to recompile bar.ml, replacing all occurence of
Foo.member by Foo1.member or Foo2.member. In other words, there seems to be
no way of choosing the Foo implementation at link-time..

Am i right or still missing the point ?... :-)

Thanks again for you patience..

--
E-mail: Jocelyn.Serot@lasmea.univ-bpclermont.fr .............................
S-mail: LASMEA - URA 1793 CNRS, Universite Blaise Pascal, 63177 Aubiere cedex
Tel: (33) 73.40.73.30 - Fax: (33) 73.40.72.62 ...............................
.... http://wwwlasmea.univ-bpclermont.fr/Personnel/Jocelyn.Serot/Welcome.html