From: John Prevost <jmp@arsdigita.com>
To: Julian Assange <proff@iq.org>
Cc: caml-list@inria.fr
Subject: Re: automatic construction of mli files
Date: 24 Jul 2000 18:09:17 -0400 [thread overview]
Message-ID: <873dkz6v02.fsf@localhost.localdomain.> (raw)
In-Reply-To: Julian Assange's message of "24 Jul 2000 15:34:22 +1000"
>>>>> "ja" == Julian Assange <proff@iq.org> writes:
ja> .mli files are highly redundant. Almost without exception all,
ja> or at the vast majority of .mli information can be generated
ja> from the underlying .ml implementation. We have programming
ja> languages to reduce redundancy, not increase it. Keeping mli
ja> and ml files in-sync is not only a waste of time, but
ja> error-prone and from my survey often not performed correctly,
ja> particularly where consistency is not enforced by the compiler
ja> (e.g comments describing functions and types). While exactly
ja> the same problem exists in a number of other
ja> separate-compilation language implementations, we, as camlers,
ja> should strive for something better.
I disagree. .mli files are not at all redundant. For one thing, if
you do not desire to use .mli files, you do not need to write them at
all--the system works perfectly well if you use only .ml files.
What .mli files are *for* is to restrict the type of a top-level
module. Within the language we may write:
module Foo =
(struct
type t = int
let foo x = x
let bar x = x + 1
let baz x = x
end : sig
type t
val foo : int -> t
val bar : t -> t
val baz : t -> int
end)
in order to restrict the visibility of types. But using top-level
modules, there's no declaration which may be wrapped in a type
constraint. .mli serves exactly this purpose.
Now--what if the language were changed to annotate such things
in-line? I argue that it would not, in fact, become a better
language. For the above, we might write:
EXTERN opaque
type t = int
EXTERN int -> t
let foo x = x
EXTERN t -> t
let bar x = x + 1
EXTERN t -> int
let baz x = x
Note that I don't actually recommend this syntax, I'm just trying to
point out what information has to be provided.
The first thing to note is that each top-level declaration must be
annotated with the type you wish to export, if you want to export
anything at all. I'm of two minds about this. On the one level,
there are good arguments for doing it that way: the type constraints
are near the code they go with. When I look at foo, I see that it's
actually meant to turn an int into a t.
On the other hand, it really breaks things up. When I see:
type t
val foo : int -> t
val bar : t -> t
val baz : t -> int
it's very easy to see what basic types and operations on those types
are provided by the module. If I want to change what information is
revealed, it's pretty easy to do.
And things get even hairier when you want to restrict things down
more from more complex types.
I personally think that making type constraints an aspect of the
module-level language, and hence not supporting inline declarations of
this sort of thing is good. If you want things to be transparent,
don't use .mli files. In general, if you want to hide anything, I
think you usually want to hide enough to make inline constraints more
confusing than not.
John.
next prev parent reply other threads:[~2000-07-25 21:52 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-07-24 5:34 Julian Assange
2000-07-24 20:48 ` Olivier Andrieu
2000-07-26 16:03 ` John Max Skaller
2000-07-24 22:02 ` Jean-Christophe Filliatre
2000-07-26 16:09 ` John Max Skaller
2000-07-24 22:09 ` John Prevost [this message]
2000-07-24 23:14 ` David Brown
2000-07-25 1:13 ` Jacques Garrigue
2000-08-01 11:22 ` Anton Moscal
2000-08-02 12:03 ` Dmitri Lomov
2000-08-02 14:13 ` Gerard Huet
2000-07-25 11:48 ` Hendrik Tews
2000-07-26 10:16 ` David Delahaye
2000-07-26 12:58 Damien Doligez
2000-07-27 17:46 ` Francois Rouaix
2000-07-27 19:04 Damien Doligez
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=873dkz6v02.fsf@localhost.localdomain. \
--to=jmp@arsdigita.com \
--cc=caml-list@inria.fr \
--cc=proff@iq.org \
/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