From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id WAA29243; Tue, 2 Jul 2002 22:48:24 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id WAA29558 for ; Tue, 2 Jul 2002 22:48:23 +0200 (MET DST) Received: from mail.eecs.harvard.edu (bowser.eecs.harvard.edu [140.247.60.24]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g62KmMP24709 for ; Tue, 2 Jul 2002 22:48:23 +0200 (MET DST) Received: by mail.eecs.harvard.edu (Postfix, from userid 33000) id 4459054C7D7; Tue, 2 Jul 2002 16:48:22 -0400 (EDT) Received: from localhost (localhost [127.0.0.1]) by mail.eecs.harvard.edu (Postfix) with ESMTP id 4269F54C7B6 for ; Tue, 2 Jul 2002 16:48:22 -0400 (EDT) Date: Tue, 2 Jul 2002 16:48:22 -0400 (EDT) From: Julie Farago To: caml-list@inria.fr Subject: [Caml-list] camlp4 and anonymous function naming In-Reply-To: <20020702.115619.74735853.avv@quasar.ipa.nw.ru> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk camlp4 hackers, I am trying to use camlp4 to name anonymous functions. I want to take code that in the form: fun -> and convert it to: let anonfunc = in anonfunc 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