English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

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,

[1] http://caml.inria.fr/oreilly-book/html/

Stefano Zacchiroli  -  Undergraduate Student of CS @ Uni. Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it}  -  http://www.bononia.it/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 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