Version française
Home     About     Download     Resources     Contact us    
Browse thread
automatic construction of mli files
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: David Brown <caml-list@d...>
Subject: Re: automatic construction of mli files
On Mon, Jul 24, 2000 at 03:34:22PM +1000, Julian Assange wrote:
 
> .mli files are highly redundant. Almost without exception all, or at
> the vast majority of .mli information can be generated from the
> underlying .ml implementation. We have programming languages to reduce
> redundancy, not increase it.

The redundancy is intentional, though.  There are two differing
philosophies concerning the information in the mli file.  One attitude,
taken by languages such as Eiffel, is that there should be no specification
file.  The source contains markers to determine what is "public" and what
is "private".  The compiler provides tools to generate specs for
documentation use.

The other attitude, taken by Ada, and sort of, but not really, by C, is
that the spec file is a document of the interface to the module.  The
implementation is independent from the spec.  The developer should feel
free to implement the spec as needed, as long as it complies with that
interface.

Both methods have advantages and disadvantages.

- The single file approach is easier for the programmer to create,
  especially when doing rapid prototyping.

- The single file approach makes it less obvious if a given change is going
  to change the interface.  A separate spec can be checked against to
  verify that the developer didn't change the interface.

- The separate spec is usually difficult for those first learning the
  language.  Ocaml helps here by not requiring the spec to be written, and
  even generating it for you.

There are very strong arguments by big names for both sides.  Ocaml, like
it does in many areas, leaves the choice up to the developer.

If you wish to have a single file, don't write a .mli file at all.  Modules
will export all symbols by default if there is no spec.  If you want to
make a spec when you are done, compile the modules with -i, and redirect
the output to the spec file.  Feel free to comment it, and delete the
symbols you didn't really want to export.

For those who wish to use a more "structured" approach to development, the
spec can be written first.  Then the compiler will verify that the code
written corresponds with the spec.

The challenge, then is to figure out which methodology I prefer :-).

Dave Brown