Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] automatic extraction of mli file?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Xavier Leroy <xavier.leroy@i...>
Subject: Re: [Caml-list] automatic extraction of mli file?
> I'm quite new in OCaml and I want to know what is the practice of the 
> OCaml programmers. Will you first write the interface files, then 
> implement, or vice versa?

Here is my recipe: you write an interface file when the interface of
your module becomes clearly defined, and you feel ready to document
the interface.

For some modules, typically data structures, this means the interface
is written first: you know that you'll need, say, doubly-linked
circular lists, and you have a fairly clear idea of what operations
you'll need.  Then, you can write the interface and some comments on
the behavior of the functions, and go ahead with writing the remainder
of the program.  Later, you'll implement the data structure.

For other modules, you'd typically start with the implementation and
no interface file, as the external interface to your module isn't
clear yet.  When it stabilizes and needs to be documented, now is the
time to write an interface file.

Think of it this way: the interface file is where you document (via
comments) the external, behavioral specification of your code.
Comments in implementation file should just be comments on how the
implementation works (e.g. "this is Kildall's worklist algorithm, as
documented in <blah> section 11.4.2").  If you ever feel like
writing a behavioral comment in an implementation file ("this function
computes this and that"), don't: create the interface file instead.

- Xavier Leroy
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners