<?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="2002/07/69515a2d7d7e36df2caff6fbd0eddfa3"
  from="Julie Farago &lt;farago@e...&gt;"
  author="Julie Farago"
  date="2002-07-02T20:48:24"
  subject="[Caml-list] camlp4 and anonymous function naming"
  prev="2002/07/562bfd7c9196fc3abcb454d8d4965868"
  next="2002/07/123444c4a1c6ba44fab849393fa7d36a"
  prev-in-thread="2002/07/562bfd7c9196fc3abcb454d8d4965868"
  next-in-thread="2002/07/8aaf29027d45ab74beaf633b7b6c51b7"
  prev-thread="2002/07/1c3e421998b8c597856d6c991ff07910"
  next-thread="2002/07/729263137a5c609a8795ff7b62ccf4d0"
  root="../../"
  period="month"
  listname="caml-list"
  title="Archives of the Caml mailing list">

<thread subject="[Caml-list] embedding OCaml into C on win32">
<msg 
  url="2002/07/562bfd7c9196fc3abcb454d8d4965868"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-02T18:59:08"
  subject="[Caml-list] embedding OCaml into C on win32">
<msg 
  url="2002/07/69515a2d7d7e36df2caff6fbd0eddfa3"
  from="Julie Farago &lt;farago@e...&gt;"
  author="Julie Farago"
  date="2002-07-02T20:48:24"
  subject="[Caml-list] camlp4 and anonymous function naming">
<msg 
  url="2002/07/8aaf29027d45ab74beaf633b7b6c51b7"
  from="Daniel de Rauglaudre &lt;daniel.de_rauglaudre@i...&gt;"
  author="Daniel de Rauglaudre"
  date="2002-07-03T08:08:10"
  subject="Re: [Caml-list] camlp4 and anonymous function naming">
</msg>
</msg>
<msg 
  url="2002/07/380f1d9276b23b4d004f27ca65e5bb07"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-02T21:33:28"
  subject="Re: [Caml-list] embedding OCaml into C on win32">
<msg 
  url="2002/07/1938bd06a7295f31e5fee044ccfdda3a"
  from="Alexander V.Voinov &lt;avv@q...&gt;"
  author="Alexander V.Voinov"
  date="2002-07-02T22:35:38"
  subject="Re: [Caml-list] embedding OCaml into C on win32">
</msg>
</msg>
</msg>
</thread>

<contents>
camlp4 hackers,

I am trying to use camlp4 to name anonymous functions. I want to take code
that in the form:
fun &lt;args&gt; -&gt; &lt;body&gt;

and convert it to:
let anonfunc&lt;number&gt; &lt;args&gt; = &lt;body&gt; in anonfunc&lt;number&gt;

I've read over the camlp4 tutorial and have some sense of how to do this,
but am getting stuck because I do not know the correct syntax to use. I
currently am extending the grammar with:

EXTEND
 expr:
   [[ "fun" ; vars = LIST1 LIDENT ; "-&gt;" ; e = expr -&gt;
         givenames loc vars e ]]
 ;
END;;

and then I try and re-write the anonymous function with:

let namefun =
  let cnt = ref 0 in
    fun var -&gt; let x = incr cnt ; !cnt in
    var ^ "_genfun" ^ string_of_int x

let givenames loc vars e =
  let name = namefun "my" in
    &lt;:expr&lt;
      let $lid:name$ $vars$ = $e$
      in $lid:name$ &gt;&gt;

This code is, of course, wrong. The problem is that I cannot figure out
how to simply capture the args from the fun and place them back into the
let.

Any direction you could provide on this would be great!
-Julie

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

