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=0.0 required=5.0 tests=none 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 EF36CBC6B for ; Wed, 25 Jul 2007 19:53:16 +0200 (CEST) Received: from ug-out-1314.google.com (ug-out-1314.google.com [66.249.92.169]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id l6PHrEIh031584 for ; Wed, 25 Jul 2007 19:53:16 +0200 Received: by ug-out-1314.google.com with SMTP id o2so379763uge for ; Wed, 25 Jul 2007 10:52:55 -0700 (PDT) Received: by 10.66.232.9 with SMTP id e9mr1532015ugh.1185385975163; Wed, 25 Jul 2007 10:52:55 -0700 (PDT) Received: from ?192.168.1.142? ( [88.58.218.58]) by mx.google.com with ESMTPS id z37sm1805244ikz.2007.07.25.10.52.53 (version=TLSv1/SSLv3 cipher=RC4-MD5); Wed, 25 Jul 2007 10:52:54 -0700 (PDT) Message-ID: <46A78DD9.2060909@netseven.it> Date: Wed, 25 Jul 2007 19:52:25 +0200 From: Massimiliano Brocchini User-Agent: Thunderbird 2.0.0.0 (X11/20070501) MIME-Version: 1.0 To: ocaml Subject: Camlp4: ctyp antiquotation and polymorphic type question References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at concorde with ID 46A78E0A.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; camlp:01 ctyp:01 ctyp:01 expr:01 camlp:01 'a-:01 vars:01 translated:01 compiler:01 foo:01 parser:01 surrounded:98 polymorphic:01 polymorphic:01 parsed:01 Hi, I have a type expression stored in a string (obtained by cmigrep) and I need to attach it to a polymorphic method definition, but I can't obtain what I expected... I tried two solutions but I miserably failed: 1) with the following code let t1 = <:ctyp<$anti:quant$>> in let t2 = <:ctyp<$anti:function_type$>> in let method_type_expanded = <:ctyp< !$t1$.$t2$ >> in <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >> I get this error message: [...] While expanding quotation "ctyp" in a position of "expr": Parse error: illegal begin of quotation of type I even tried using a list instead of the first ctyp (t1) as mentioned in the old camlp4 3.07 manual: let method_type_expanded = <:ctyp< !$list:var_list$.$t2$ >> in but it doesn't work. 2) I tried building the polymorphic methods type declaration (e.g. 'a 'b. 'a->'b) by concatenation of strings let method_type = (vars ^ " . " ^ function_type) in let method_type_expanded = <:ctyp<$anti:method_type$>> in <:class_str_item< method $x$ : $method_type_expanded$ = $expression$ >> compiles and works to some extent... it adds the antiquotation in the translated .ml file which has two problems: - it is an unparsed string, so no compiler checks on it - it is surrounded by $ (e.g. method foo : $ 'a. 'a list -> 'a$ = ....) Could you please explain how to have the antiquotation correctly parsed by camlp4? Am I on the wrong path? (I don't feel like writing a parser for type expressions :( ). Regards, Massimiliano Brocchini (camlp4 beginner)