Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: Probleme d'interface
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Bouzid Djamila <Bouzid.Djamila@l...>
Subject: Re: Probleme d'interface

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.