caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: "Claudio Russo" <crusso@microsoft.com>
To: "Alain Frisch" <frisch@clipper.ens.fr>
Cc: "Brian Rogoff" <bpr@best.com>, "Caml list" <caml-list@inria.fr>
Subject: RE: first class, recursive, mixin modules (was: RE: first class modules)
Date: Thu, 11 Jan 2001 10:32:43 -0000	[thread overview]
Message-ID: <112C6E8A1B25D34BB27D48D2FD2E96CFC9DED4@TVP-MSG-02.europe.corp.microsoft.com> (raw)

> Are there real examples using recursive modules with these 
> restrictions ?

Well, it depends on what do you mean by real...
They are useful, together with first-class modules, for doing object
encodings (albeit rather heavy ones). 
You get polymorphic recursion for free (but at the cost of the dynamic
check, which could be optimized away in this case), but there are
simpler mechanisms for this.
Chris Okasaki's elegant bootstrapped heap implementation requires them
(+ other features)
 (see the mosml distribution).
They are probably useful for things like CORBA to ML bindings that use
the ML modules language to capture
the structure of the mutually recursive IDL interfaces. 
An then there's the example of the Ocaml modules/core typechecker that
you mention.


> You can always define everything outside the structures (or 
> in the first
> one), then copy the types and values in the structures. Of course, you
> loose the modularity of definitions, but with recursive modules as in
> MosML, you loose the static typing for the module language (Bind
> exceptions) and also the modularity (different source files;
> separate compilation). 

I'm not sure what you meant by losing static typing. It's just that
typing for
recursive modules now gives you a weaker property --- either the
recursive expression evaluates or
raises the exception Bind. It never  seg faults. I think it would be
possible to refine the type system
to detect unsafe recursion and avoid dynamic checks for safe recursion,
but this is alot more work and may well
interact with other features of the type system. Note that it is already
possible to use a syntactic criterion to avoid some dynamic checks
(something like those under functions that don't get called in the
recursive module), as an optimisation. And of course, you can always
still use the reference tying trick of Ocala.

> If you accept runtime checks, the solution adopted
> in the OCaml compiler to break the circle of dependencies between
> the Core and Module type checkers (forward declaration with a 
> reference
> updated when the definition is available) has the advantage 
> of retaining
> separate compilation.

But this only works for mutually recursive functions that span module
boundaries, not datatype definitions.
You'll note in the caml sources that the abstract syntax tree and typed
abstract syntax tree for module
are defined in a single datatype definition, not separately. Although
it's possible to separate them out
using type parameters, this is pretty inconvenient in practice. 

> Back to first class packaged modules: a very useful feature 
> for runtime
> configuration of applications would be the possibility to load the
> packages from the disk/network (that is, dynamic loading; the
> signature of trusted packages can be checked as in the 
> Dynlink module).

This shouldn't be too difficult. I have an example of using that used
Moscow ML's Dynlib library to construct
an ADT to a C shared library, if it exists, and default ADT otherwise.
This is similar to what you want, except for
loading a C library.
 
Cheers, 
Claudio
 



             reply	other threads:[~2001-01-11 17:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-01-11 10:32 Claudio Russo [this message]
  -- strict thread matches above, loose matches on Subject: below --
2001-01-10 10:32 first class modules (was: alternative module systems) Claudio Russo
2001-01-10 21:34 ` first class, recursive, mixin modules (was: RE: first class modules) Alain Frisch

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=112C6E8A1B25D34BB27D48D2FD2E96CFC9DED4@TVP-MSG-02.europe.corp.microsoft.com \
    --to=crusso@microsoft.com \
    --cc=bpr@best.com \
    --cc=caml-list@inria.fr \
    --cc=frisch@clipper.ens.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).