caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Stefan Heimann <lists@stefanheimann.net>
To: caml-list@inria.fr
Subject: Re: Re: [Caml-list] Automatic generation of mli files
Date: Fri, 6 Jun 2003 17:59:32 +0200	[thread overview]
Message-ID: <20030606155932.GA12058@kunz.ratzer> (raw)
In-Reply-To: <Pine.LNX.4.33.0306061027580.2857-100000@eagle.ancor.com>

On Fri, Jun 06, 2003 at 10:33:25AM -0500, Brian Hurt wrote:
> On Fri, 6 Jun 2003, Stefan Heimann wrote:
> 
> > Hi,
> > 
> > I searching for a way for generating the .mli file for a given source .ml
> > file automatically. My basic idea is like that:
> > 
> > (1) Specify in the .ml file which values and types should be exported
> >     and if a type should be exported abstract or not. This could be
> >     done with a special comment at the top of the file.
> > 
> > (2) Filter the output of `ocamlc -i' to exclude the values and types
> >     that should not be exported and to make the types abstract if
> >     needed.
> 
> Not sure what advantage this would gain.  Step #1 is about as difficult as 
> simply writting the .mli file directly.  Actually, a fairly fast way to 
> produce an mli file is to do ocamlc -i foo.ml > foo.mli and fire up your 
> local text editor and delete everything out of foo.mli you don't want 
> exported.

I don't think that step #1 is as difficult as writing the .mli file by
hand. If you have a complex type definition it's much easier to write
`export my_type' than keeping the 2 definitions in the .ml and .mli file
in sync.
 
> I don't have a problem with .mli files being seperate from .ml files for 
> two reasons:

It is not my problem that there is this separation between interface
and implementation file. I think this is very good and helpful,
especially when you want to see what functionality a module
provides. I just want to make it easier to write the implementation
file. Programmers are lazy and so writing an interface file should be
as easy as possible.

> 1) .mli is your external interface- changing that interface generally 
> means changing other files as well.  In this case, you're generally 
> already chaging other files.
> 
> 2) The compiler checks the signature of the .mli file against what is 
> produced by the .ml file, so if you do "accidentally" change an exported 
> function's interface, and forget to change the .mli to match, the compiler 
> will catch it.

Maybe I should tell how I want to use the tool. I don't want to update
the .mli file automatically everytime I change something in the .ml
file. I want to use the compiler as I would do without the tool. The
tool comes only into play when the compiler complains about a
non-matching implementation for the interface. Then I have to decide
if this is because I "accidentally" changed something in the
implementation. If yes, I change to implementation. If no, I use to
tool to update to .mli file instead of applying the changes by hand.

Bye,
  Stefan

-- 
Stefan Heimann
http://www.stefanheimann.net :: personal website.
http://cvsshell.sf.net       :: CvsShell, a console based cvs client.

-------------------
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


  reply	other threads:[~2003-06-06 15:59 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-06  9:57 Stefan Heimann
2003-06-06 11:53 ` Maxence Guesdon
2003-06-06 15:33 ` Brian Hurt
2003-06-06 15:59   ` Stefan Heimann [this message]
2003-06-06 16:17     ` Ville-Pertti Keinonen
2003-06-06 18:30   ` Chris Hecker
2003-06-06 19:16     ` Brian Hurt
2003-06-06 19:21       ` Chris Hecker
2003-06-06 21:06         ` Manos Renieris
2003-06-06 22:06           ` Chris Hecker
2003-06-06 20:24       ` Stefan Heimann
2003-06-06 20:38         ` Jeffrey J. Cook
     [not found]           ` <200306091226.13255.yangsx@fltrp.com>
2003-06-09  4:59             ` Yang Shouxun
2003-06-09  8:10               ` Stefan Heimann
2003-06-07  0:27       ` John Max Skaller

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=20030606155932.GA12058@kunz.ratzer \
    --to=lists@stefanheimann.net \
    --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).