<?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="2003/01/7b6361f24dd6b0d3f8de50aee87acff6"
  from="Vitaly Lugovsky &lt;vsl@o...&gt;"
  author="Vitaly Lugovsky"
  date="2003-01-15T19:15:53"
  subject="[Caml-list] let rec"
  prev="2003/01/7b4356fccebf28ce028122d7511e4854"
  next="2003/01/5c69412226d2da8af89577d8948de944"
  next-in-thread="2003/01/5c69412226d2da8af89577d8948de944"
  prev-thread="2003/01/a2655a29f853a3b70108ffd4274e4fa2"
  next-thread="2003/01/b5d0186ce6e333fe2b6c01d25588830a"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] let rec">
<msg 
  url="2003/01/7b6361f24dd6b0d3f8de50aee87acff6"
  from="Vitaly Lugovsky &lt;vsl@o...&gt;"
  author="Vitaly Lugovsky"
  date="2003-01-15T19:15:53"
  subject="[Caml-list] let rec">
<msg 
  url="2003/01/5c69412226d2da8af89577d8948de944"
  from="james woodyatt &lt;jhw@w...&gt;"
  author="james woodyatt"
  date="2003-01-15T19:27:40"
  subject="Re: [Caml-list] let rec">
<msg 
  url="2003/01/a13b46421e57a3e347d0f6a9ef72e5c5"
  from="Vitaly Lugovsky &lt;vsl@o...&gt;"
  author="Vitaly Lugovsky"
  date="2003-01-15T19:54:15"
  subject="Re: [Caml-list] let rec">
</msg>
</msg>
<msg 
  url="2003/01/cb8a88ca7e675f77b1cc337427964d72"
  from="Max Kirillov &lt;max630@m...&gt;"
  author="Max Kirillov"
  date="2003-01-15T20:02:54"
  subject="Re: [Caml-list] let rec">
</msg>
<msg 
  url="2003/01/49346985c07b882018e2ad7569519596"
  from="Mike Potanin &lt;potanin@m...&gt;"
  author="Mike Potanin"
  date="2003-01-16T14:22:20"
  subject="Re: [Caml-list] let rec">
<msg 
  url="2003/01/5826a692c94d64d6a3a75f199aeb2599"
  from="Damien Doligez &lt;damien.doligez@i...&gt;"
  author="Damien Doligez"
  date="2003-01-18T12:07:12"
  subject="Re: [Caml-list] let rec">
<msg 
  url="2003/01/c7db60a6b7108f7caa0b0773e608a824"
  from="Mike Potanin &lt;potanin@m...&gt;"
  author="Mike Potanin"
  date="2003-01-18T15:14:37"
  subject="Re: [Caml-list] let rec">
</msg>
<msg 
  url="2003/01/9511ec7e9c82e947ddfb16fe055f6d91"
  from="Vitaly Lugovsky &lt;vsl@o...&gt;"
  author="Vitaly Lugovsky"
  date="2003-01-18T16:22:34"
  subject="Re: [Caml-list] let rec">
</msg>
</msg>
</msg>
</msg>
</thread>

<contents>

 For a closure-driven "compilers" I have to use for
a recursion something like this:

    let xprs = ref (fun _ -&gt; Lnil) in
    let f (il,al,ht) =
      let il2 = Array.make (n2+1) Lnil in
      acopy il il2;
      Array.iteri (fun i x -&gt; il2.(all.(i)) &lt;- x) al;
      !xprs (il2,anul,ht)
    in xprs :=
      (Hashtbl.replace ht name (CTfun(f)); (* Insert f into the env2
                                              environment *)
       compile_exprs env2 exprs);
    f

 It's not so funny. Why I can't write it using let rec:

    let rec f (il,al,ht) =
      let il2 = Array.make (n2+1) Lnil in
      acopy il il2;
      Array.iteri (fun i x -&gt; il2.(all.(i)) &lt;- x) al;
      xprs (il2,anul,ht)
    and xprs =
      (Hashtbl.replace ht name (CTfun(f));
       compile_exprs env2 exprs) in
    f

 Sure, let rec construction should be much less restrictive.

 And, another one question: does ocaml compiler really eliminates
unused variables from the closure environment?

-------------------
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

</contents>

</message>

