From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by yquem.inria.fr (Postfix) with ESMTP id 5A6B7BC69 for ; Tue, 20 Mar 2007 11:28:10 +0100 (CET) Received: from animal.inescn.pt (ns.inescn.pt [192.35.246.1]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l2KAS9bO032022 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO) for ; Tue, 20 Mar 2007 11:28:10 +0100 Received: from localhost (localhost [127.0.0.1]) by animal.inescn.pt (8.13.8/8.13.6/9) with ESMTP id l2KAS7m4020499 for ; Tue, 20 Mar 2007 10:28:07 GMT X-Virus-Scanned: amavisd-new at inescporto.pt Received: from animal.inescn.pt ([127.0.0.1]) by localhost (animal.inescn.pt [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 7Z+w8PvpU3oc for ; Tue, 20 Mar 2007 10:27:49 +0000 (WET) Received: from [194.117.30.94] (morfina.inescn.pt [194.117.30.94]) by animal.inescn.pt (8.13.8/8.13.8/11) with ESMTP id l2KARe61020358 for ; Tue, 20 Mar 2007 10:27:40 GMT Message-ID: <45FFB71B.3080002@inescporto.pt> Date: Tue, 20 Mar 2007 10:27:39 +0000 From: Hugo Ferreira User-Agent: Thunderbird 1.5.0.10 (X11/20070305) MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: camlp4: processing lists Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 45FFB739.001 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 camlp:01 expr:01 expr:01 iter:01 endline:01 pcaml:01 pcaml:01 iter:01 endline:01 syntax:01 cmo:01 cmo:01 ppo:01 ppo:01 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.