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 DAA03588; Mon, 14 Jan 2002 03:34:13 +0100 (MET) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id DAA03624 for ; Mon, 14 Jan 2002 03:34:12 +0100 (MET) Received: from c007.snv.cp.net (c007-h014.c007.snv.cp.net [209.228.33.221]) by nez-perce.inria.fr (8.11.1/8.11.1) with SMTP id g0E2YAT00648 for ; Mon, 14 Jan 2002 03:34:11 +0100 (MET) Received: (cpmta 16671 invoked from network); 13 Jan 2002 18:34:09 -0800 Received: from 65.187.194.217 (HELO vaiobambino) by smtp.directvinternet.com (209.228.33.221) with SMTP; 13 Jan 2002 18:34:09 -0800 X-Sent: 14 Jan 2002 02:34:09 GMT From: "Jeff Henrikson" To: Cc: Subject: RE: [Caml-list] camlp4: LIST1 construct on record patterns Date: Sun, 13 Jan 2002 21:49:56 -0500 Message-ID: <005601c19ca6$265b33e0$0b01a8c0@mit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook 8.5, Build 4.71.2173.0 Importance: Normal X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200 In-Reply-To: <005501c19ca1$a4b249e0$0b01a8c0@mit.edu> Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Wait, sorry again, I figured out the correct type: let lbl_expr_list = (Obj.magic (Grammar.Entry.find expr "lbl_expr_list") : (MLast.patt * MLast.expr) list Grammar.Entry.e) in as you said, then "car" the first list element and it's right: [ [ $cons$; "{"; memb = LIST1 lbl_expr_list SEP ";" ; "}" -> (let memb0= List.nth memb 0 in <:expr<{$list:memb0$}>>) ] ] I don't understand it though. Is there some explanation? Jeff > -----Original Message----- > From: owner-caml-list@pauillac.inria.fr > [mailto:owner-caml-list@pauillac.inria.fr]On Behalf Of Jeff Henrikson > Sent: Sunday, January 13, 2002 9:18 PM > To: Daniel de Rauglaudre > Cc: caml-list@inria.fr > Subject: RE: [Caml-list] camlp4: LIST1 construct on record patterns > > > 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 > ------------------- 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