* [Caml-list] camlp4 'loc' variable
@ 2004-02-22 18:06 J. Garrett Morris
2004-02-22 18:57 ` Stefano Zacchiroli
2004-02-23 1:10 ` Aleksey Nogin
0 siblings, 2 replies; 3+ messages in thread
From: J. Garrett Morris @ 2004-02-22 18:06 UTC (permalink / raw)
To: caml-list
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?
Thanks.
Gary
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] camlp4 'loc' variable
2004-02-22 18:06 [Caml-list] camlp4 'loc' variable J. Garrett Morris
@ 2004-02-22 18:57 ` Stefano Zacchiroli
2004-02-23 1:10 ` Aleksey Nogin
1 sibling, 0 replies; 3+ messages in thread
From: Stefano Zacchiroli @ 2004-02-22 18:57 UTC (permalink / raw)
To: caml-list
On Sun, Feb 22, 2004 at 01:06:47PM -0500, J. Garrett Morris wrote:
> which are used both in antiquotations and in let statements
> surrounding expr quotations ... when do I need to take 'loc' as a
> parameter?
The camlp4 manual states that the loc variable is bound in the "action"
part of a "level-rules" (i.e. the right hand side of an -> arrow in a
grammar production).
Therefore I guess you should pass loc as a parameter if you invoke
functions from those RHSs which are not defined inside a RHS.
Cheers.
--
Stefano Zacchiroli -*- Computer Science PhD student @ Uny Bologna, Italy
zack@{cs.unibo.it,debian.org,bononia.it} -%- http://www.bononia.it/zack/
If there's any real truth it's that the entire multidimensional infinity
of the Universe is almost certainly being run by a bunch of maniacs. -!-
-------------------
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Caml-list] camlp4 'loc' variable
2004-02-22 18:06 [Caml-list] camlp4 'loc' variable J. Garrett Morris
2004-02-22 18:57 ` Stefano Zacchiroli
@ 2004-02-23 1:10 ` Aleksey Nogin
1 sibling, 0 replies; 3+ messages in thread
From: Aleksey Nogin @ 2004-02-23 1:10 UTC (permalink / raw)
To: gXm, Caml List
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
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2004-02-23 8:24 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-02-22 18:06 [Caml-list] camlp4 'loc' variable J. Garrett Morris
2004-02-22 18:57 ` Stefano Zacchiroli
2004-02-23 1:10 ` Aleksey Nogin
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox