Version française
Home     About     Download     Resources     Contact us    
Browse thread
Lazy modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Dario Teixeira <darioteixeira@y...>
Subject: RE: [Caml-list] Lazy modules
Hi,

> AFAIK local modules is a syntax extension not a compiler
> extension - I expect (not looked at it) that the syntax
> extension simply alpha renames all the local module
> declarations to make them unique and puts them globally... a
> very useful extension but no expressive power added.

But if that were true, wouldn't the functor instantiation happen at
initialisation time, thus preventing the delayed instantiation that
is key for this solution to work?


> I believe that the module system due for OCaml 3.12.0 will
> allow this kind of runtime application of functors as
> modules are first class values.

Again, I'm under the impression that functor application can already
(with 3.11 at least) occur at runtime when local modules are used.
(Or are you talking about different things?).  For example:

# module Foo (S: sig end) = struct let () = print_endline "foo!" end;;
module Foo : functor (S : sig  end) -> sig  end

# let hello () = let module F = Foo (struct end) in ();;
val hello : unit -> unit = <fun>

# hello ();;
foo!
- : unit = ()


> Hope that's helpful - the inability to do what you're
> wanting to do is one of the reasons that I've never delved
> deeply into the module system - powerful as it may be, it
> didn't seem to be able to help performing a simple task
> (similar to yours) that I wanted it to do (I have also in
> the past wanted to exactly what you're doing - i.e. a module
> of loaded configuration values).

Yep, Alain confirmed that modules as first-class values are indeed
coming for 3.12.  Ocaml's module system just got more interesting...

Cheers,
Dario Teixeira