From: Hugo Ferreira <hmf@inescporto.pt>
To: caml-list@yquem.inria.fr
Subject: camlp4: processing lists
Date: Tue, 20 Mar 2007 10:27:39 +0000 [thread overview]
Message-ID: <45FFB71B.3080002@inescporto.pt> (raw)
Hello,
I have sent this post to the new ocaml-developer list but am resending
it here in the hopes that someone can help me. I have come across a
weirdness in camlp4. Maybe someone can explain this puzzle to me.
I have the following extension:
let expand_term_list loc l =
let nl = <:expr< [] >> in
let nl = List.fold_right (fun h t ->
<:expr< [$h$::$t$] >>
) l nl in
<:expr<
do {
List.iter (fun i -> print_endline i) $nl$
}
>>
EXTEND
Pcaml.expr: [
[
"|" ; "[" ; l = LIST0 Pcaml.expr SEP ";" ; "]" ; "|"->
expand_term_list loc l ] ];
END;;
I compile the source below with the camlp4 extension above:
....
let t1 =
List.iter (fun i -> print_endline i) ["1"; "f(X,Y)"; "g(X,Y)"; "4"]
in
()
And the execution gives me:
4
If I generate the original and revised syntax output using the extension
above using for example:
camlp4o -I . pr_o.cmo pa_$(NAME).cmo $(PROG).ml -o $(PROG).ppo
camlp4o -I . pr_r.cmo pa_$(NAME).cmo $(PROG).ml -o $(PROG).ppr
I get for $(PROG).ppo
...
let t1 =
List.iter (fun i -> print_endline i) ["1"; "f(X,Y)"; "g(X,Y)"; "4"]
in
()
which is what I expect for the original syntax... but for the revised
syntax $(PROG).ppr I get:
let t1 =
do {
print_string "Not implemented for list ";
List.iter (fun i -> print_endline i)
[do { "1"; "f(X,Y)"; "g(X,Y)"; "4" }]
}
in
()
which ... to say the least is *not* what I expected. I initially I
though I had but one Pcaml.expr and not a list of those. What seems
to be happening is that the revised syntax is used to generate the
code and this is wrong.
Can anyone tell me what mess I have done?
TIA,
Hugo Ferreira.
next reply other threads:[~2007-03-20 10:28 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-03-20 10:27 Hugo Ferreira [this message]
2007-03-20 10:54 ` [Caml-list] " Nicolas Pouillard
2007-03-20 11:14 ` Hugo Ferreira
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=45FFB71B.3080002@inescporto.pt \
--to=hmf@inescporto.pt \
--cc=caml-list@yquem.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;
as well as URLs for NNTP newsgroup(s).