Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] choosing modules at runtime
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alessandro Baretta <alex@b...>
Subject: Re: [Caml-list] choosing modules at runtime


Henri Dubois-Ferriere wrote:
> Say I have a module signature M which is implemented by module structs 
> M_1, M_2, M_3, .. M_N.
> 
> At runtime , depending on some command-line parameters, I will choose one 
> of the module implementations (they use different algorithms internally). 

I do the same in my application. I have a module defining a 
module type which provider modules must implement. I then 
dynamically link a cmo specified on the command line, which 
implements the module type. This file registers the exported 
functions and values with Registry module, through which 
they are called and used by the application. Not a simple 
scheme, but useful and appropriate in my case.

> This means my main code will be littered with things like
> 
> if (use algorithm 1) then
> M_1.run_algo()
> else if (use algorithm 2) then
> M_2.run_algo() ...

Dynlink solves this problem. But, I'll admit, conditional 
module expressions would be a cool, cool feature. And I 
don't believe this requires first class modules.


Alex

-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners