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.4 required=5.0 tests=AWL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail1-relais-roc.national.inria.fr (mail1-relais-roc.national.inria.fr [192.134.164.82]) by yquem.inria.fr (Postfix) with ESMTP id 80E6EBBCA for ; Fri, 18 Apr 2008 09:19:43 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: ApsEAMrnB0jAXQIn/2dsb2JhbACKe6FO X-IronPort-AV: E=Sophos;i="4.25,676,1199660400"; d="asc'?scan'208";a="11058467" Received: from concorde.inria.fr ([192.93.2.39]) by mail1-smtp-roc.national.inria.fr with ESMTP; 18 Apr 2008 09:19:43 +0200 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by concorde.inria.fr (8.13.6/8.13.6) with ESMTP id m3I7Jgmi022350 (version=TLSv1/SSLv3 cipher=RC4-SHA bits=128 verify=OK) for ; Fri, 18 Apr 2008 09:19:42 +0200 X-IronPort-AV: E=Sophos;i="4.25,676,1199660400"; d="asc'?scan'208";a="11598148" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail3-relais-sop.national.inria.fr with SMTP; 18 Apr 2008 09:19:41 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Fri, _d Apr 2008 09:19:36 +0200 From: "Nicolas Pouillard" Cc: caml-list Subject: Re: [Caml-list] [camlp4] str_item filters & toplevel? To: Martin Jambon References: <1208443348-sup-5838@ausone.inria.fr> <1208457210-sup-4981@ausone.local> In-Reply-To: Date: Fri, 18 Apr 2008 09:19:31 +0200 Message-Id: <1208502844-sup-984@ausone.local> User-Agent: Sup/git Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="=-1208503176-86958-79442-2389-10-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Miltered: at concorde with ID 48084B8E.000 by Joe's j-chkmail (http://j-chkmail . ensmp . fr)! X-Spam: no; 0.00; 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 caml-list:01 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1208503176-86958-79442-2389-10-= Content-Type: text/plain; charset=UTF-8 Excerpts from Martin Jambon's message of Thu Apr 17 21:19:44 +0200 2008: > 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 Currently both can be implemented on a per file basis, moreover they are implemented by using the *same* registering construct. > made available in the toplevel without theoretical difficulties. If one don't add new registration functions the behavior will be odd. > 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. So in the toplevel, filters registered using register_str_item_filter will be called once on an empty phrase. And a new function register_toplevel_phrase_filter will gather functions to be called on each toplevel phrase. > >> If it's already fixed, which version? > > > > Not already fixed. -- Nicolas Pouillard aka Ertai --=-1208503176-86958-79442-2389-10-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkgIS4QACgkQj+FCNw9dwLlOkQCfcv/CSVBPweew1kJ5cMZ1fN8K gwUAn2XRb0e+VZHjKsJmwvIxliks0fXj =LsXh -----END PGP SIGNATURE----- --=-1208503176-86958-79442-2389-10-=--