caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Re: [Caml-list] load modules by name
@ 2003-01-28 13:42 rich
  2003-01-28 15:56 ` Yann Régis-Gianas
  2003-01-28 17:47 ` Nicolas Cannasse
  0 siblings, 2 replies; 5+ messages in thread
From: rich @ 2003-01-28 13:42 UTC (permalink / raw)
  To: caml-list

It's possible I'm missing something here, but am I right in thinking
there's no way to do introspection on a module? eg. find out what
functions / classes it contains?

Rich.

-- 
Richard Jones
http://www.annexia.org/ Freshmeat projects: http://freshmeat.net/users/rwmj
-------------------
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


^ permalink raw reply	[flat|nested] 5+ messages in thread
* [Caml-list] load modules by name
@ 2003-01-21  7:22 Pietro Abate
  2003-01-21 10:48 ` Stefano Zacchiroli
  0 siblings, 1 reply; 5+ messages in thread
From: Pietro Abate @ 2003-01-21  7:22 UTC (permalink / raw)
  To: caml-list

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


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-01-28 16:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-28 13:42 [Caml-list] load modules by name rich
2003-01-28 15:56 ` Yann Régis-Gianas
2003-01-28 17:47 ` Nicolas Cannasse
  -- strict thread matches above, loose matches on Subject: below --
2003-01-21  7:22 Pietro Abate
2003-01-21 10:48 ` Stefano Zacchiroli

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