caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Pietro Abate <Pietro.Abate@anu.edu.au>
To: caml-list@inria.fr
Subject: [Caml-list] load modules by name
Date: Tue, 21 Jan 2003 18:22:28 +1100	[thread overview]
Message-ID: <20030121072228.GA6481@anu.edu.au> (raw)

hi list,

I'm trying to figure out how I can build a kind of associative list
to load a specific module at runtime. I've reread few old messages about
first-class modules and other oddities, but I've the sensation my
problem is easier.

I have a library (compiled), an application (compiled) and a bunch of
user defined modules (that are compiled as well, but these may be vary
in number). At the moment the application select the rigth module
statically regarding a command line argument. However this way I must
recompile my application everytime I add a new module.

What I'd like to do is reading all .cmo files (or .ml files and compile
them on the fly) in a directory and build a kind of assoc list with 
(name,module) and at runtime select the right module.

let's say that now I have

let algo = 
match command_line_option with
| "mod1" -> Module1.algo
| "mod2" -> Module2.algo
...
| _ -> failwith "module not defined"
in ...

but I'd rather have something like

let algo =
	try
		List.assoc "command_line_option" assoclist
	with Not_found -> failwith "Module not defined"
in ...

That would not require any recompilation of my application.

It would also nice to compile on the fly these modules...
I'm thinking of something like eval in perl...

is it possible ?

p

-------------------
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


             reply	other threads:[~2003-01-21  7:17 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-01-21  7:22 Pietro Abate [this message]
2003-01-21 10:48 ` Stefano Zacchiroli
2003-01-22 16:41 ` [Caml-list] " Michaël Grünewald
2003-01-28 13:42 [Caml-list] " rich
2003-01-28 15:56 ` Yann Régis-Gianas
2003-01-28 17:47 ` Nicolas Cannasse

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20030121072228.GA6481@anu.edu.au \
    --to=pietro.abate@anu.edu.au \
    --cc=caml-list@inria.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).