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 4AD59BBCA for ; Sat, 5 Apr 2008 12:00:24 +0200 (CEST) X-IronPort-AV: E=Sophos;i="4.25,608,1199660400"; d="asc'?scan'208";a="10469544" Received: from peray.inria.fr (HELO ausone.inria.fr) ([128.93.8.98]) by mail1-relais-roc.national.inria.fr with SMTP; 05 Apr 2008 12:00:23 +0200 Received: by ausone.inria.fr (sSMTP sendmail emulation); Sat, _d Apr 2008 12:00:23 +0200 From: "Nicolas Pouillard" Cc: Caml_mailing list Subject: Re: [Caml-list] Camlp4: example/parse_files.ml To: Hendrik Tews References: <18420.4901.506029.744640@tandem.cs.ru.nl> <1207236568-sup-3680@port-ext16.ensta.fr> <1207316266-sup-9155@ausone.inria.fr> <1207318438-sup-662@ausone.inria.fr> In-Reply-To: Date: Sat, 05 Apr 2008 12:00:23 +0200 Message-Id: <1207389369-sup-3263@ausone.local> User-Agent: Sup/git Content-Type: multipart/signed; protocol="application/pgp-signature"; boundary="=-1207389623-754650-7786-1032-4-="; micalg="pgp-sha1" MIME-Version: 1.0 X-Spam: no; 0.00; camlp:01 hendrik:01 doable:01 functors:01 camlp:01 cmo:01 cmo:01 syntax:01 syntax:01 callbacks:01 functor:01 parsed:01 caml-list:01 writes:01 functorial:02 X-Attachments: cset="UTF-8" type="application/pgp-signature" name="signature.asc" name="signature.asc" --=-1207389623-754650-7786-1032-4-= Content-Type: text/plain; charset=UTF-8 Excerpts from Hendrik Tews's message of Fri Apr 04 23:30:58 +0200 2008: > "Nicolas Pouillard" writes: > > I think that's doable (not tested), basically you need three > primitive functors: > > I don't see how. Let me clarify again what I mean. And let me > clarify that I only pursue this discussion out of curiosity, to > see, what can be done with the functorial Camlp4 interface. > > Assume we have a table like this: > > s1.cmo s2.cmo ... : f1.ml f2.ml ... > s3.cmo s4.cmo ... : f3.ml f4.ml ... > > The sx.cmo files are Camlp4 syntax extentions and the fx.ml are > files to be parsed using those syntax extentions. There are a > number of possible solutions: > - starting camlp4 for each file or each row > - clearing PreCast.Syntax before each row and then calling the > callbacks that the syntax extensions registered > > But I would like to know if the functorial Camlp4 design is > strong enough to solve this exercise within one program (without > fork/exec) and without reusing/clearing one syntax module. > > It is clear that the registration in Register.SyntaxExtension is > not good enough, because it always applies the syntax extension > to PreCast.Syntax. > > However, even with changing Register.SyntaxExtension or how > syntax extensions register themselves, I can't see a solution. That's some corner case where first-class modules would help a lot, however one can use some black magic under the hood to get the same effect. One need to store extensions once and for all, in a map from names to "modules". Then one can have some function (functor) that takes a list modules names and an initial module, and will apply these extensions to it. -- Nicolas Pouillard aka Ertai --=-1207389623-754650-7786-1032-4-= Content-Disposition: attachment; filename="signature.asc" Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.8 (Darwin) iEYEARECAAYFAkf3TbcACgkQj+FCNw9dwLliugCgl025NDo/NRn0GR1kEOC/e9aZ tjYAn0imqX7fpcytcnIDxBe2z8SfMV12 =Kahe -----END PGP SIGNATURE----- --=-1207389623-754650-7786-1032-4-=--