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 mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by yquem.inria.fr (Postfix) with ESMTP id 75E81BBCA for ; Thu, 17 Apr 2008 21:21:26 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApcAAPs/B0hCbwQZk2dsb2JhbACRXQEBAQEJAwkJFpsa X-IronPort-AV: E=Sophos;i="4.25,673,1199660400"; d="scan'208";a="25132291" Received: from concorde.inria.fr ([192.93.2.39]) by mail4-smtp-sop.national.inria.fr with ESMTP; 17 Apr 2008 21:21:26 +0200 Received: from mail4-relais-sop.national.inria.fr (mail4-relais-sop.national.inria.fr [192.134.164.105]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m3HJLP6D002317 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Thu, 17 Apr 2008 21:21:26 +0200 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApcAAPs/B0hCbwQZk2dsb2JhbACRXQEBAQEJAwkJFpsa X-IronPort-AV: E=Sophos;i="4.25,673,1199660400"; d="scan'208";a="25132290" Received: from out1.smtp.messagingengine.com ([66.111.4.25]) by mail4-smtp-sop.national.inria.fr with ESMTP; 17 Apr 2008 21:21:24 +0200 Received: from compute1.internal (compute1.internal [10.202.2.41]) by out1.messagingengine.com (Postfix) with ESMTP id AA8AEFE740; Thu, 17 Apr 2008 15:21:23 -0400 (EDT) Received: from heartbeat1.messagingengine.com ([10.202.2.160]) by compute1.internal (MEProxy); Thu, 17 Apr 2008 15:21:23 -0400 X-Sasl-enc: iKdz6L0kLvCLHMElyojlCSSZwQrzqCfyxFP7XXLlLyGn 1208460083 Received: from [192.168.1.10] (ALyon-157-1-140-124.w90-42.abo.wanadoo.fr [90.42.147.124]) by mail.messagingengine.com (Postfix) with ESMTPSA id 744B9D423; Thu, 17 Apr 2008 15:21:22 -0400 (EDT) Date: Thu, 17 Apr 2008 21:19:44 +0200 (CEST) From: Martin Jambon X-X-Sender: martin@martin.ec.wink.com To: Nicolas Pouillard Cc: caml-list Subject: Re: [Caml-list] [camlp4] str_item filters & toplevel? In-Reply-To: <1208457210-sup-4981@ausone.local> Message-ID: References: <1208443348-sup-5838@ausone.inria.fr> <1208457210-sup-4981@ausone.local> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Miltered: at concorde with ID 4807A335.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; ens-lyon:01 camlp:01 toplevel:01 wiki:01 camlp:01 toplevel:01 patching:01 bug:01 bug:01 inserting:01 foo:01 inserting:01 hacks:01 wrote:01 wrote:01 On Thu, 17 Apr 2008, Nicolas Pouillard wrote: > Excerpts from Martin Jambon's message of Thu Apr 17 17:25:20 +0200 2008: >> On Thu, 17 Apr 2008, Nicolas Pouillard wrote: >> >>> Excerpts from Martin Jambon's message of Thu Apr 17 16:17:15 +0200 2008: >>>> I started from the wiki page describing how to use AST filters: >>>> http://brion.inria.fr/gallium/index.php/Camlp4MapGenerator >>>> >>>> The example doesn't work in the toplevel (3.10.1), although it works >>>> otherwise. How to make it work? >>> >>> By patching the camlp4 sources :) >> >> Is it a bug that has to be fixed? > > It could be seen as a bug, but the behavior is not completely clear, since > applying the filters to each toplevel phrase is different from calling them > only once on the whole module implem. Thanks. I'll look at the code for a better understanding. I think that the 2 following cases are pretty common: a. inserting some constant code once at the beginning of the file (or module), such as "open Foo" b. replacing a str_item by other str_items Both were problematic in camlp4 3.09, requiring some fragile or undocumented hacks. It would be extremely useful to have a clean solution to these problems. It seems to me that both (a) and (b) could be implemented and made available in the toplevel without theoretical difficulties. I can imagine a third situation consisting in performing a full file/module analysis and inserting something at the beginning or at the end. That also could be implemented, although it would clearly not be available in the toplevel. Martin >> If it's already fixed, which version? > > Not already fixed. > > -- > Nicolas Pouillard aka Ertai -- http://wink.com/profile/mjambon http://mjambon.com