From: Julie Farago <farago@eecs.harvard.edu>
To: caml-list@inria.fr
Subject: [Caml-list] camlp4 and anonymous function naming
Date: Tue, 2 Jul 2002 16:48:22 -0400 (EDT) [thread overview]
Message-ID: <Pine.BSF.4.44.0207021635090.78988-100000@bowser.eecs.harvard.edu> (raw)
In-Reply-To: <20020702.115619.74735853.avv@quasar.ipa.nw.ru>
camlp4 hackers,
I am trying to use camlp4 to name anonymous functions. I want to take code
that in the form:
fun <args> -> <body>
and convert it to:
let anonfunc<number> <args> = <body> in anonfunc<number>
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 ; "->" ; e = expr ->
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 -> let x = incr cnt ; !cnt in
var ^ "_genfun" ^ string_of_int x
let givenames loc vars e =
let name = namefun "my" in
<:expr<
let $lid:name$ $vars$ = $e$
in $lid:name$ >>
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
next prev parent reply other threads:[~2002-07-02 20:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-07-02 18:56 [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
2002-07-02 20:48 ` Julie Farago [this message]
2002-07-03 8:08 ` [Caml-list] camlp4 and anonymous function naming Daniel de Rauglaudre
2002-07-02 21:30 ` [Caml-list] embedding OCaml into C on win32 Alexander V.Voinov
2002-07-02 22:32 ` Alexander V.Voinov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Pine.BSF.4.44.0207021635090.78988-100000@bowser.eecs.harvard.edu \
--to=farago@eecs.harvard.edu \
--cc=caml-list@inria.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox