<?xml version="1.0" encoding="ISO-8859-1"?>

<!DOCTYPE message PUBLIC
  "-//MLarc//DTD MLarc output files//EN"
  "../../mlarc.dtd"[
  <!ATTLIST message
    listname CDATA #REQUIRED
    title CDATA #REQUIRED
  >
]>

  <?xml-stylesheet href="../../mlarc.xsl" type="text/xsl"?>


<message 
  url="2006/02/6f98d2c26e5095e71bb6eaa96087bdde"
  from="Nathan Cooprider &lt;coop@c...&gt;"
  author="Nathan Cooprider"
  date="2006-02-21T00:54:44"
  subject="Rephrasing of dynamic module selection problem"
  prev="2006/02/55a2a2db63e4e329bd4be58d1bf1c5ee"
  next="2006/02/2e21262671d26ca4956db3bbfcf39ca0"
  next-in-thread="2006/02/166e73eb9483d32d01c6586a068b6d68"
  prev-thread="2006/02/c00cd9129fc81180e4199583825836cf"
  next-thread="2006/02/e6065b7bd89d7f0ba4c9a94c8db316b9"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="Rephrasing of dynamic module selection problem">
<msg 
  url="2006/02/6f98d2c26e5095e71bb6eaa96087bdde"
  from="Nathan Cooprider &lt;coop@c...&gt;"
  author="Nathan Cooprider"
  date="2006-02-21T00:54:44"
  subject="Rephrasing of dynamic module selection problem">
<msg 
  url="2006/02/166e73eb9483d32d01c6586a068b6d68"
  from="Martin Jambon &lt;martin_jambon@e...&gt;"
  author="Martin Jambon"
  date="2006-02-21T03:50:53"
  subject="Re: &quot;ocaml_beginners&quot;::[] Rephrasing of dynamic module selection problem">
</msg>
<msg 
  url="2006/02/0010bbc7928d8dab73de090fe6fab8fc"
  from="brogoff &lt;brogoff@s...&gt;"
  author="brogoff"
  date="2006-02-21T03:55:53"
  subject="Re: [Caml-list] Rephrasing of dynamic module selection problem">
<msg 
  url="2006/02/368bb3c5a0430f6328ee3b5f7ee8bd03"
  from="Andreas Rossberg &lt;AndreasRossberg@w...&gt;"
  author="Andreas Rossberg"
  date="2006-02-21T12:13:55"
  subject="Re: [Caml-list] Rephrasing of dynamic module selection problem">
</msg>
</msg>
<msg 
  url="2006/02/4a8e69b079aae473911bfc0b65e93fab"
  from="Virgile Prevosto &lt;virgile.prevosto@m...&gt;"
  author="Virgile Prevosto"
  date="2006-02-21T12:14:10"
  subject="Re: [Caml-list] Rephrasing of dynamic module selection problem">
</msg>
</msg>
</thread>

<contents>
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 -&gt; Hello1
  | _ -&gt; Hello2
 *)

let argument = 42
let main () =
  H.print (H.of_int argument) ;;
main ();;

[coop@ender example]$ cpp main.ml &gt; 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

</contents>

</message>

