Walter Cazzola wrote:
> Hi,
> thanks Cedric i got the point, I can separate interface from the
> implementation but:

The main point of interfaces is to constrain the inferred interface of a module 
(e.g. hide functions or types which shouldn't be exposed to another module or 
constraint polymorphic variables to a specific type). It's not like C - you're 
not declaring a header file which you then usually include in the 
implementation itself (and, yes, it does unfortunately result in some code 
duplication - at least in terms of type definitions)

>   - if I use the module keyword I have to qualify the use of the module
>     through the file name and the interface file should have a base name
>     different from the implementation file

Yes, because the module is a sub-module of the module defined by the file.

>   - otherwise the file itself can be considered a module and I can remove
>     module, struct and sig keywords from the code and have the same name
>     for the interface and implementation file.

It's not that the file "can be considered a module" - it entirely is a module 
with the case sensitive (except for the first character) filename being the 
module name (so module Foo should be kept in foo.ml or Foo.ml)

> Thanks a lot from the guide all these details are missing or very well
> hidden.

Chapter 2 of the manual "The module system", section 5 "Modules and separate 
compilation" - http://caml.inria.fr/pub/docs/manual-ocaml/manual004.html#toc17


David

<snipped>


-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to