From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id IAA03029; Tue, 21 Jan 2003 08:17:01 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id IAA03164 for ; Tue, 21 Jan 2003 08:17:00 +0100 (MET) Received: from axiom.anu.edu.au (axiom.anu.edu.au [150.203.127.200]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id h0L7Gvr23715 for ; Tue, 21 Jan 2003 08:16:58 +0100 (MET) Received: from pulp.anu.edu.au (pulp.anu.edu.au [150.203.126.25]) by axiom.anu.edu.au (8.11.2/8.11.2/SuSE Linux 8.11.1-0.5) with ESMTP id h0L7Gte32558 (using TLSv1/SSLv3 with cipher EDH-RSA-DES-CBC3-SHA (168 bits) verified NO) for ; Tue, 21 Jan 2003 18:16:55 +1100 Received: from pulp.anu.edu.au (localhost [127.0.0.1]) by pulp.anu.edu.au (8.12.7/8.12.7/Debian-2) with ESMTP id h0L7MSZ7006610 for ; Tue, 21 Jan 2003 18:22:28 +1100 Received: (from abate@localhost) by pulp.anu.edu.au (8.12.7/8.12.7/Debian-2) id h0L7MSCr006608 for caml-list@inria.fr; Tue, 21 Jan 2003 18:22:28 +1100 Date: Tue, 21 Jan 2003 18:22:28 +1100 From: Pietro Abate To: caml-list@inria.fr Subject: [Caml-list] load modules by name Message-ID: <20030121072228.GA6481@anu.edu.au> Mail-Followup-To: Pietro Abate , caml-list@inria.fr Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Operating-System: GNU/Linux X-Organization: Research School of Information Science and Engineering (Austrialian National University) User-Agent: Mutt/1.5.3i Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk 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