From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from weis@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id XAA13361 for caml-red; Tue, 25 Jul 2000 23:55:12 +0200 (MET DST) Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id BAA27930 for ; Tue, 25 Jul 2000 01:14:05 +0200 (MET DST) Received: from davidb.org ([216.103.8.60]) by concorde.inria.fr (8.10.0/8.10.0) with SMTP id e6ONE4j16821 for ; Tue, 25 Jul 2000 01:14:04 +0200 (MET DST) Received: (qmail 3692 invoked by uid 1403); 24 Jul 2000 23:14:02 -0000 Date: Mon, 24 Jul 2000 16:14:02 -0700 From: David Brown To: Julian Assange Cc: caml-list@inria.fr Subject: Re: automatic construction of mli files Message-ID: <20000724161401.B3623@opus.davidb.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2i In-Reply-To: ; from proff@iq.org on Mon, Jul 24, 2000 at 03:34:22PM +1000 Sender: weis@pauillac.inria.fr 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