From: Alain Frisch <alain@frisch.fr>
To: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Questions concerning modules as first-class values
Date: Wed, 02 Jun 2010 18:28:07 +0200 [thread overview]
Message-ID: <4C068697.5050007@frisch.fr> (raw)
In-Reply-To: <AANLkTik5APhKZJVEt0ke1MR3_Uj4zF8Sla317pxvTArE@mail.gmail.com>
On 06/02/2010 03:43 PM, Julien Signoles wrote:
> If I well understood what Alain Frisch and Xavier Leroy explained,
> modules (including both structures and functors) become first class
> value: structures may be converted to records and functors to functions;
> and conversely. But I let more informed person confirm this.
Not really. What you describe is the internal compilation strategy for
modules (structures -> records; functors -> functions), which did not
change with the introduction of 1st class modules.
What's possible in OCaml 3.12 is to turn a module (be it a structure or
a functor) into a "package", which is a first-class value. A package is
just the wrapper around a module that makes it a first-class value. In
particular, a package that wraps a structure (resp. a functor) is *not*
converted to a record (resp. a function).
What you can with a package:
- whatever you can do with a first-class value (pass it to a function,
store it in a data structure, etc);
- unwrap it back into the underlying module.
We've been using first-class modules for more than one year at LexiFi
and we have never found a use for packing functors into first-class
values, but I've no doubt people will find some. In particular, this
allows the program to decide at runtime (given an environment variable
or a command-line argument) to use some particular (functorized)
implementation of a data structure over another.
Alain
next prev parent reply other threads:[~2010-06-02 16:28 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-02 13:14 Dario Teixeira
2010-06-02 13:43 ` [Caml-list] " Julien Signoles
2010-06-02 16:28 ` Alain Frisch [this message]
[not found] ` <21533_1275496091_o52GSC5l015052_4C068697.5050007@frisch.fr>
2010-06-02 17:36 ` Eric Cooper
2010-06-03 15:31 ` Alain Frisch
2010-06-04 1:34 ` Jacques Garrigue
2010-06-04 4:59 ` Alain Frisch
2010-06-02 14:05 Dario Teixeira
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=4C068697.5050007@frisch.fr \
--to=alain@frisch.fr \
--cc=caml-list@yquem.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