Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

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: 2002-10-12 (12:43)
From: Sven LUTHER <luther@d...>
Subject: Re: [Caml-list] automatic extraction of mli file?
On Sat, Oct 12, 2002 at 07:50:55PM +0800, Yang Shouxun wrote:
> Nicolas Cannasse wrote:
> >>What I'm wondering is "wouldn't it be preferrable to automatically
> >>produce the interface file from the implementation file?", so that we
> >>can program in the literate programming style, do prototyping, and save
> >>the drudgery of writing the interface (though a little manual editing
> >>may be necessary, or some kind of markup in the source code).
> >The "-i" ocamlc compiler flag is what you need.
> This seems to be not what I mean. OK, that is what I asked :(.
> All the comments will be removed. That is not desirable, for the mli 
> file is meant to be read by both machine and humans. The humans need the 
> comments to make sense of the interface file, without reference to the 
> implementation code.

Well, in general, you write the .ml, and once you are satisfied, you can
generate the .mli, and adapt it to your need : add comments, remove
uneeded info, etc.

Later one, you have to maintain both files separatedly. The idea being
that the .mli is the contract that the .ml has with its users, so
basically you can improve on the .ml, without changing much its

Another way of programming, is writting the .mli first, so it correspond
to what you want, and then write the implementation of it.

But any way you do it, normally you don't change the .mli very much
after the first writing, so it is ok to maintain it by hand.


Sven Luther
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: