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 MAA10572; Tue, 24 Sep 2002 12:08:09 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id MAA11052 for ; Tue, 24 Sep 2002 12:08:08 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (fichte.ai.univie.ac.at [131.130.174.156]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g8OA87D04222 for ; Tue, 24 Sep 2002 12:08:07 +0200 (MET DST) Received: from fichte.ai.univie.ac.at (markus@localhost [127.0.0.1]) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian -4) with ESMTP id g8OA86EI007113; Tue, 24 Sep 2002 12:08:06 +0200 Received: (from markus@localhost) by fichte.ai.univie.ac.at (8.12.3/8.12.3/Debian -4) id g8OA859Z007112; Tue, 24 Sep 2002 12:08:05 +0200 Date: Tue, 24 Sep 2002 12:08:05 +0200 From: Markus Mottl To: Henri DF Cc: caml-list@inria.fr Subject: Re: [Caml-list] choosing modules at runtime Message-ID: <20020924100805.GA31883@fichte.ai.univie.ac.at> Mail-Followup-To: Henri DF , caml-list@inria.fr References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4i Organization: Austrian Research Institute for Artificial Intelligence Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On Tuesday, 24 Sep 2002, Henri Dubois-Ferriere wrote: > At runtime , depending on some command-line parameters, I will choose one > of the module implementations (they use different algorithms internally). [snip] > Am I missing something obvious here? Of course what I would conceptually > like to do would be something like > > let Mod = if (use algorithm 1) then M_1 else if (use alg 2) then M_2 .. > > and then be able to call Mod.run_algo(), but that probably belies that I > am still thinking in an OO manner... What you are actually looking for is first class modules, i.e. modules, which can be passed around at runtime. This topic has already popped up a couple of times in the past, especially since Claudio Russo implemented them along the lines of his PhD-thesis for Moscow ML. Here is a link to the start of such a thread: http://caml.inria.fr/archives/200101/msg00054.htm Unfortunately, I haven't heard of any efforts to integrate this extension into the main distribution of OCaml. I do indeed have quite a few sources that would benefit from first class modules. Parameterization of algorithms can be quite painful without. E.g., I have a large number of modules implementing various machine learning heuristics that all have their own concrete types and algorithms but match the same signature. Depending on some command-line arguments I'd like to use some of them as arguments to a functor to instantiate a machine learning system. If I didn't use some absolutely awful workarounds (extracting functions from modules and passing tuples of them around just to recreate the modules elsewhere), I'd even suffer from combinatorial explosion, because I'd have to consider the Cartesian product of all possible functor applications. I'd really highly appreciate some extensions to the module system that make such things simpler... Best regards, Markus Mottl -- Markus Mottl markus@oefai.at Austrian Research Institute for Artificial Intelligence http://www.oefai.at/~markus ------------------- 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