Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] load modules by name
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2003-01-21 (18:56)
From: Stefano Zacchiroli <zack@b...>
Subject: Re: [Caml-list] load modules by name
On Tue, Jan 21, 2003 at 06:22:28PM +1100, Pietro Abate wrote:
> is it possible ?

Yes, just use the Dynlink module.

You can find a great usage example in the O'Reilly book [1] (debian
package available in debian/unstable ocaml-book-{en,fr}).

Anyway, returning to your example you should have an association list
ref, say "algos", and you should use it as

  let algo =
      List.assoc "command_line_option" !algos
   with Not_found -> failwith "Module not loaded"

Then you should have a set of .cmos that you should load using
'Dynlink.loadfile', each module should update the 'algos' association
list adding itself to it.

Hope this helps,


Stefano Zacchiroli  -  Undergraduate Student of CS @ Uni. Bologna, Italy
zack@{,,}  -
"  I know you believe you understood what you think I said, but I am not
sure you realize that what you heard is not what I meant!  " -- G.Romney
To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: