caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: David Allsopp <dra-news@metastack.com>
To: OCaML Mailing List <caml-list@inria.fr>
Subject: RE: [Caml-list] separate compilation
Date: Fri, 9 Sep 2011 07:06:36 +0000	[thread overview]
Message-ID: <E51C5B015DBD1348A1D85763337FB6D9C24446D8@Remus.metastack.local> (raw)
In-Reply-To: <alpine.LFD.2.00.1109090725180.2407@surtur.dico.unimi.it>

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>


      reply	other threads:[~2011-09-09  7:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-08 14:26 Walter Cazzola
2011-09-08 14:33 ` Philippe Wang
2011-09-08 14:40   ` Walter Cazzola
2011-09-08 14:33 ` Esther Baruk
2011-09-08 14:42   ` Walter Cazzola
2011-09-08 15:55     ` AUGER Cedric
2011-09-09  6:50       ` Walter Cazzola
2011-09-09  7:06         ` David Allsopp [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=E51C5B015DBD1348A1D85763337FB6D9C24446D8@Remus.metastack.local \
    --to=dra-news@metastack.com \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).