Re: Probleme d'interface

Bouzid Djamila (Bouzid.Djamila@loria.fr)
Fri, 14 Jun 1996 17:45:23 +0200 (MET DST)

From: Bouzid Djamila <Bouzid.Djamila@loria.fr>
Message-Id: <199606141545.RAA19033@delsarte.loria.fr>
Subject: Re: Probleme d'interface
To: lux@heidelbg.ibm.com (Wolfgang Lux)
Date: Fri, 14 Jun 1996 17:45:23 +0200 (MET DST)
In-Reply-To: <9606140921.AA32629@idse.heidelbg.ibm.com> from "Wolfgang Lux" at Jun 14, 96 11:21:04 am

Hi!

Thanks for all responses that I have received.

> The problem simply is, that you have to define both modules types
> VENDOR_INTEGER and VENDOR in vendor.ml as well to compile.

So I have mixed vendor.mli and vendor.ml in a single file vendor.ml.

(* vendor.ml *)

module type VENDOR_INTEGER =
sig
val min : int * int -> int
end (* sig *)

module type VENDOR =
sig
val print: string -> unit
(* Flush the standard out. *)
module Integer : VENDOR_INTEGER
end (* sig *)

module type TIMINGBOARD = sig end

module V (TimingBoard: TIMINGBOARD) : VENDOR =
struct
let print = print_string
module Integer : VENDOR_INTEGER =
struct
let min(x,y) = if x < y then x else y
end
end (* functor V *)

(*end of vendor.ml)

So the compilation is

finot ip 61 % cslc vendor.ml
I/O error: vendor.cmi: No such file or directory
finot ip 62 %

What means this error, if vendor.cmi is generated in compilation.

> But actually this is not what you really want, as the local module V
> is not visible at all outside of vendor.ml! (And in contrary to your
> comment it is not a functor!)

I have'nt inderstood why module V is not visible at all outside in this
case of vendor.ml. ^^^

>
> If you look into the Caml Special Light reference,

please, could you tell me where can I find this reference ?
I have only Caml Special Light reference manual, I want to have
more references of this language.

you will see that
> the files vendor.mli and vendor.ml constitute themselves a module
> which is roughly equivalent to
>
> module Vendor :
> sig
> <<contents of vendor.mli>>
> end =
> struct
> <<contents of vendor.ml>>
> end
>
> So you wanted probably to write the following module interface vendor.mli:
>
> module type VENDOR_INTEGER =
> sig
> val min : int * int -> int
> end (* sig *)
>
> val print: string -> unit
> module Integer : VENDOR_INTEGER
>
> And your implementation vendor.ml then would look as follows:
>
> module type VENDOR_INTEGER =
> sig
> val min : int * int -> int
> end
>
> let print = print_string
> module Integer : VENDOR_INTEGER =
> struct
> let min ((x:int),(y:int)) = if x < y then x else y
> end
>

But if we want have

module V : VENDOR =
.......
end (*V*)

module V1 = V
module V2 = V

or

module V (....) : VENDOR =
struct
......
end (*functor*)

What should I do ?

>
> Hope this helps,

Thanks a lot.

D. Bouzid.