From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 49BFBBBBB for ; Tue, 21 Feb 2006 01:54:44 +0100 (CET) Received: from mail-svr1.cs.utah.edu (mail-svr1.cs.utah.edu [155.98.64.241]) by nez-perce.inria.fr (8.13.0/8.13.0) with ESMTP id k1L0shI9007277 for ; Tue, 21 Feb 2006 01:54:43 +0100 Received: from localhost (localhost [127.0.0.1]) by mail-svr1.cs.utah.edu (Postfix) with ESMTP id 80CCB65007B; Mon, 20 Feb 2006 17:54:42 -0700 (MST) Received: from mail-svr1.cs.utah.edu ([127.0.0.1]) by localhost (mail-svr1.cs.utah.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 14687-06; Mon, 20 Feb 2006 17:54:39 -0700 (MST) Received: from [192.168.0.4] (63-225-58-110.slkc.qwest.net [63.225.58.110]) by smtps.cs.utah.edu (Postfix) with ESMTP id DB93B650079; Mon, 20 Feb 2006 17:54:34 -0700 (MST) Message-ID: <43FA64C8.1050704@cs.utah.edu> Date: Mon, 20 Feb 2006 17:54:32 -0700 From: Nathan Cooprider User-Agent: Mozilla Thunderbird 1.0.7-1.1.fc3 (X11/20050929) X-Accept-Language: en-us, en MIME-Version: 1.0 To: ocaml_beginners@yahoogroups.com, caml-list@yquem.inria.fr Subject: Rephrasing of dynamic module selection problem Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Virus-Scanned: amavisd-new at cs.utah.edu X-Miltered: at nez-perce with ID 43FA64D3.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; run-time:01 statically:01 compile-time:01 struct:01 struct:01 cpp:01 foo:01 ocamlc:01 foo:01 nathan:98 coop:98 selectable:98 bellow:98 coop:98 nathan:98 X-Spam-Checker-Version: SpamAssassin 3.0.3 (2005-04-27) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.8 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.0.3 So I am still trying to get modules to be dynamically (run-time) selectable instead of only statically (compile-time). The closest I have come to so far is bellow. I want to be able to choose between a set of modules (hello1 and hello2 in this example) fairly transparently. [coop@ender example]$ cat hello1.ml type t = int let of_int i = i let print i = print_int i; print_string " says Hello1\n" [coop@ender example]$ cat hello2.ml type t = float let of_int i = float_of_int i let print i = print_float i; print_string " says Hello2\n" [coop@ender example]$ cat main.ml module Hello1 = struct #include "hello1.ml" end ;; module Hello2 = struct #include "hello2.ml" end ;; (* This works . . . *) module H = Hello1 (* But I would like this to be something like this instead: let parameter = 1 module H = match parameter with 1 -> Hello1 | _ -> Hello2 *) let argument = 42 let main () = H.print (H.of_int argument) ;; main ();; [coop@ender example]$ cpp main.ml > foo.ml ; ocamlc foo.ml ; rm foo.ml ; a.out 42 says Hello1 In my real application, there are five different modules (and I am adding more after I get this working) and they have around fifty functions in them. Nathan