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.0 required=5.0 tests=AWL,SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from discorde.inria.fr (discorde.inria.fr [192.93.2.38]) by yquem.inria.fr (Postfix) with ESMTP id CD04CBC89 for ; Fri, 1 Jun 2007 15:44:44 +0200 (CEST) Received: from nz-out-0506.google.com (nz-out-0506.google.com [64.233.162.235]) by discorde.inria.fr (8.13.6/8.13.6) with ESMTP id l51DihqU012696 for ; Fri, 1 Jun 2007 15:44:44 +0200 Received: by nz-out-0506.google.com with SMTP id s18so450497nze for ; Fri, 01 Jun 2007 06:44:43 -0700 (PDT) DKIM-Signature: a=rsa-sha1; c=relaxed/relaxed; d=gmail.com; s=beta; h=domainkey-signature:received:received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=igxEvuqWnPSmeNl80V1HxCGJTuJoE84BCXFBkLsnCGid6K/XHf4XR8H69Hc1eRrkzREXVlM39igrISsHI4QskIpp0yrqrAa1Y/J8IVYNmloctM/X+vEa5Ke4kBU1dtnuZ40nToNUcyO4sT864Yc0wW1OLniuLgWbeFRj8VZpGBU= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=beta; h=received:in-reply-to:references:mime-version:content-type:message-id:cc:content-transfer-encoding:from:subject:date:to:x-mailer; b=jkB/5rNhYqb5bfNV+okFm6v5gSI1l8Hw8vVjfgwk3vMiZR+2ZO8qgvCYv1R1esyyuBUIiA4oG7xym9XTYK1Bfadw7+DhrA0jPqWFBTOitebchXZRIWhPyhvYydgTM1ApwbMUOjl0J1SBIQ2kp5Mb2NkFt+8PHULufI7mzvu/TwA= Received: by 10.65.100.14 with SMTP id c14mr3208198qbm.1180705482978; Fri, 01 Jun 2007 06:44:42 -0700 (PDT) Received: from ?192.168.1.33? ( [81.32.170.248]) by mx.google.com with ESMTP id 7sm15940nfv.2007.06.01.06.44.40; Fri, 01 Jun 2007 06:44:41 -0700 (PDT) In-Reply-To: References: <5F8F1647-A4A8-4C71-9958-9370C44ECB84@gmail.com> <979C8DFA-180A-4AA2-8D5A-63083BDDAEE7@gmail.com> <534D9E1D-8F72-4972-8F53-DA64CA2DD20B@gmail.com> <465FB7D6.1090805@gmail.com> Mime-Version: 1.0 (Apple Message framework v752.3) Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <617B5749-ACF6-4992-A447-67BC699A7083@gmail.com> Cc: "OCaml List" Content-Transfer-Encoding: 7bit From: Joel Reymont Subject: Re: [Caml-list] Re: GenerateFold Date: Fri, 1 Jun 2007 14:44:46 +0100 To: Nicolas Pouillard X-Mailer: Apple Mail (2.752.3) X-j-chkmail-Score: MSGID : 466022CB.002 on discorde : j-chkmail score : XXX : 5/20 1 0.000 -> 3 X-Miltered: at discorde with ID 466022CB.002 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; byte:01 usr:01 ocamlc:01 camlp:01 -pp:01 cmo:01 bool:01 bool:01 expr:01 expr:01 decl:01 decl:01 camlp:01 val:01 struct:01 Doesn't work! On Jun 1, 2007, at 2:30 PM, Nicolas Pouillard wrote: > Got it: > > There is the solution available for meditation :) To be precise, I don't know if it works or not. I think the fold generator bombs out. I have no idea how to debug this but, again, it has nothing to do with the implementation of is_fun_arg. Simply using GenerateFold triggers the error. Notice that everything but class fold = ... is commented out. I'm including everything needed to reproduce the error, just in case. ocamlbuild c.byte + /usr/local/bin/ocamlc.opt -c -I +camlp4 -pp 'camlp4of -I src - filter map -filter fold -filter trash ' -o b.cmo b.ml File "ghost-location", line 1, characters 0-0: This expression has type < array : 'b. ('a -> 'b -> 'a) -> 'b array -> 'a; bool : bool -> 'a; expr : A.expr -> 'a; float : float -> 'a; id : A.id -> 'a; input_decl : A.input_decl -> 'a; int : int -> 'a; list : 'c. ('a -> 'c -> 'a) -> 'c list -> 'a; option : 'd. ('a -> 'd -> 'a) -> 'd option -> 'a; order : A.order -> 'a; order_type : A.order_type -> 'a; program : A.program -> 'a; ref : 'e. ('a -> 'e -> 'a) -> 'e ref -> 'a; statement : A.statement -> 'a; string : string -> 'a; subscript : A.subscript -> 'a; ty : A.ty -> 'a; .. > as 'a but is here used with type A.order_type cat b.ml open A class fold = Camlp4Filters.GenerateFold.generated;; (* let is_fun_arg = object inherit fold as super val found = false method found = found method input_decl x = match x with | `FunArgDecl _ -> {< found = true >} | _ -> super#input_decl x end let is_fun x = (is_fun_arg#statement x)#found;; *) module Camlp4Trash = struct INCLUDE "a.ml";; end;; cat a.ml type id = string and program = statement list and ty = [ | `TyAny ] and statement = [ | `Skip | `InputDecls of input_decl list ] and subscript = expr list and input_decl = [ | `InputDecl of id * ty * expr | `FunArgDecl of id * ty * subscript ] and expr = [ | `Int of int | `Float of float | `Str of string ] and order = { order_type: order_type; } and order_type = [ | `Buy | `Sell | `Short | `Cover ] cat c.ml open A open B cat _tags "b.ml": use_camlp4, pp(camlp4of -I src -filter map -filter fold - filter trash ) -- http://topdog.cc - EasyLanguage to C# translator http://wagerlabs.com - Blog