From: "Jeff Henrikson" <jehenrik@yahoo.com>
To: "Daniel de Rauglaudre" <daniel.de_rauglaudre@inria.fr>
Cc: <caml-list@inria.fr>
Subject: RE: [Caml-list] camlp4: LIST1 construct on record patterns
Date: Sun, 13 Jan 2002 21:17:40 -0500 [thread overview]
Message-ID: <005501c19ca1$a4b249e0$0b01a8c0@mit.edu> (raw)
In-Reply-To: <20020113144823.E24240@verdot.inria.fr>
I actually tried magicing it into what I wanted it to be before, but was unable to guess it's real type. Apparently I still can't:
open Printf;;
let try_extend _ =
let cons = "Bogus" in
let lbl_expr_list =
(Obj.magic (Grammar.Entry.find expr "lbl_expr_list") :
(MLast.patt * MLast.expr) (* not list *) Grammar.Entry.e) in
EXTEND
expr: LEVEL "simple"
[ [ $cons$; "{"; memb = LIST1 lbl_expr_list SEP ";" ; "}" ->
<:expr<{$list:memb$}>> ] ]
;
END;;
try_extend 7;;
Bogus{foo="happy";bar="sad"};;
This segfaults. Let's see if memb is even a list:
let try_extend _ =
let cons = "Bogus" in
let lbl_expr_list =
(Obj.magic (Grammar.Entry.find expr "lbl_expr_list") :
(MLast.patt * MLast.expr) (* not list *) Grammar.Entry.e) in
EXTEND
expr: LEVEL "simple"
[ [ $cons$; "{"; memb = LIST1 lbl_expr_list SEP ";" ; "}" ->
(printf "Do we get here %d\n" (List.length memb); flush stdout;
<:expr<6>>) ] ]
;
END;;
try_extend 7;;
Bogus{foo="happy";bar="sad"};;
This prints "Do we get here 1", regardless of how many terms I add in Bogus{}, regardless of whether such constructors are defined
or not.
But despite all this the source code looks convincing enough:
pa_o.ml:
| "{"; test_label_eq; lel = lbl_expr_list; "}" ->
<:expr< { $list:lel$ } >>
> Sorry, Luke, you entered the dark side of Camlp4... :-)
Apparently the force is not strong enough within me. ;-}
Jeff
-------------------
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
next prev parent reply other threads:[~2002-01-14 2:02 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2002-01-13 5:38 Jeff Henrikson
2002-01-13 13:48 ` Daniel de Rauglaudre
2002-01-14 2:17 ` Jeff Henrikson [this message]
2002-01-14 2:49 ` Jeff Henrikson
2002-01-14 5:10 ` Daniel de Rauglaudre
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='005501c19ca1$a4b249e0$0b01a8c0@mit.edu' \
--to=jehenrik@yahoo.com \
--cc=caml-list@inria.fr \
--cc=daniel.de_rauglaudre@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