Browse thread
Questions concerning modules as first-class values
[
Home
]
[ Index:
by date
|
by threads
]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
| Date: | -- (:) |
| From: | Alain Frisch <alain@f...> |
| Subject: | Re: [Caml-list] Questions concerning modules as first-class values |
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