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 KAA08753; Tue, 24 Sep 2002 10:52:50 +0200 (MET DST) 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 KAA08904 for ; Tue, 24 Sep 2002 10:52:49 +0200 (MET DST) Received: from lcavpc41.epfl.ch (lcavpc41.epfl.ch [128.178.8.81]) by nez-perce.inria.fr (8.11.1/8.11.1) with ESMTP id g8O8qnD01699 for ; Tue, 24 Sep 2002 10:52:49 +0200 (MET DST) Received: from localhost (henridf@localhost) by lcavpc41.epfl.ch (8.11.6/8.11.6) with ESMTP id g8O8mtU15514 for ; Tue, 24 Sep 2002 10:48:55 +0200 X-Authentication-Warning: lcavpc41.epfl.ch: henridf owned process doing -bs Date: Tue, 24 Sep 2002 10:48:55 +0200 (CEST) From: Henri Dubois-Ferriere X-X-Sender: henridf@lcavpc41.epfl.ch Reply-To: Henri DF To: caml-list@inria.fr Subject: [Caml-list] choosing modules at runtime Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Say I have a module signature M which is implemented by module structs M_1, M_2, M_3, .. M_N. At runtime , depending on some command-line parameters, I will choose one of the module implementations (they use different algorithms internally). This means my main code will be littered with things like if (use algorithm 1) then M_1.run_algo() else if (use algorithm 2) then M_2.run_algo() ... each time I use a function from the signature M. Of course I could do a shorthand hack like let run_algo = if (use algorithm 1) then M_1.run_algo else if (use algorithm 2) then M_2.run_algo ... and then simply call run_algo from then on. (But this needs to be done for every function/value that the signature M exports). 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... Thanks for any hints on the matter. Henri ------------------- 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