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 JAA03297; Mon, 23 Feb 2004 09:24:54 +0100 (MET) 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 JAA03592 for ; Mon, 23 Feb 2004 09:24:52 +0100 (MET) Received: from dell.nogin.org (charter-242-037.caltech.edu [131.215.242.37]) by concorde.inria.fr (8.12.10/8.12.10) with ESMTP id i1N8Ooae016498 for ; Mon, 23 Feb 2004 09:24:51 +0100 Received: from cs.caltech.edu (localhost.localdomain [127.0.0.1]) by dell.nogin.org (8.12.11/8.12.9) with ESMTP id i1N1AblY017390; Sun, 22 Feb 2004 17:10:37 -0800 Message-ID: <4039530D.9000001@cs.caltech.edu> Date: Sun, 22 Feb 2004 17:10:37 -0800 From: Aleksey Nogin Organization: California Institute of Technology, Computer Science Department User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7a) Gecko/20040115 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: gXm , Caml List Subject: Re: [Caml-list] camlp4 'loc' variable References: <30597310@newdasher.Dartmouth.EDU> In-Reply-To: <30597310@newdasher.Dartmouth.EDU> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde by Joe's j-chkmail ("http://j-chkmail.ensmp.fr")! X-Loop: caml-list@inria.fr X-Spam: no; 0.00; caml-list:01 camlp:01 camlp:01 helper:01 mlast:01 expr:01 mlast:01 expr:01 exuid:01 exuid:01 626:99 cmo:01 cmo:01 caltech:01 caltech:01 Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk On 22.02.2004 10:06, J. Garrett Morris wrote: > Hello, > > I'm currently writing a set of camlp4 quotations, and I'm running into the "Unbound value 'loc'" error that's been discussed on this list before. I'm curious about exactly when the loc variable needs to be present, though. I've got a fair number of helper routines like: > > let processList (l:MLast.expr list):MLast.expr = > List.fold_right (fun x l -> <:expr<[$x$ :: $l$]>>) l <:expr<[]>> > > which are used both in antiquotations and in let statements surrounding expr quotations ... when do I need to take 'loc' as a parameter? Basically, whenever you have an <:expr< ... >> quotation used an expression, it will use the "loc" variable for the "location" part of the expression. For example, in your case <:expr<[$x$ :: $l$]>> expands to MLast.ExApp (loc, MLast.ExApp (loc, MLast.ExUid (loc, "::"), x), l) and <:expr<[]>> expands to MLast.ExUid (loc, "[]") You can find out how camlp4 expands things by running, for example, "camlp4 q_MLast.cmo pa_o.cmo pr_o.cmo your_file.ml" - the output will contain the "plain" ML code. Hope this helps. -- Aleksey Nogin Home Page: http://nogin.org/ E-Mail: nogin@cs.caltech.edu (office), aleksey@nogin.org (personal) Office: Jorgensen 70, tel: (626) 395-2907 ------------------- 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