From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (from majordomo@localhost) by pauillac.inria.fr (8.7.6/8.7.3) id AAA16549; Fri, 25 Oct 2002 00:33:51 +0200 (MET DST) X-Authentication-Warning: pauillac.inria.fr: majordomo set sender to owner-caml-list@pauillac.inria.fr using -f Received: from concorde.inria.fr (concorde.inria.fr [192.93.2.39]) by pauillac.inria.fr (8.7.6/8.7.3) with ESMTP id AAA16534 for ; Fri, 25 Oct 2002 00:33:50 +0200 (MET DST) Received: from nef.ens.fr (nef.ens.fr [129.199.96.32]) by concorde.inria.fr (8.11.1/8.11.1) with ESMTP id g9OMXn527859 for ; Fri, 25 Oct 2002 00:33:49 +0200 (MET DST) Received: from clipper.ens.fr (clipper-gw.ens.fr [129.199.1.22]) by nef.ens.fr (8.10.1/1.01.28121999) with ESMTP id g9OMXnB40016 for ; Fri, 25 Oct 2002 00:33:49 +0200 (CEST) Received: from localhost (frisch@localhost) by clipper.ens.fr (8.12.3/jb-1.1) id g9OMXmE7004648 for ; Fri, 25 Oct 2002 00:33:48 +0200 (MET DST) Date: Fri, 25 Oct 2002 00:33:48 +0200 (MET DST) From: Alain Frisch To: Caml list Subject: [Caml-list] Camlp4: syntax extension in source file Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-milter (http://amavis.org/) Sender: owner-caml-list@pauillac.inria.fr Precedence: bulk Hello, This thread about macro definition with Camlp4 reminds me of an idea I had some time ago. The idea is to use the Toplevel lib to introduce Caml syntax extension directly inside source file. Something like that: SYNTAX let x = .... EXTEND expr: [ .... ]; END END The code between SYNTAX and END is parsed, compiled and executed by Camp4 during the preprocessing phase; it modifies the syntax used to parsed the remaining of the rest of the file (including perhaps following SYNTAX ... END statements). This allows a limited kind of reflexivity: the source file describes its own syntax. It also gives the possibility to perform some computations at compile time (the "x" above). I cannot remember why I didn't succeed to make it work (I think I had some problems because of limitations in what the toplevel library exports). Daniel - and others - do you believe the above proposition makes sense ? -- Alain ------------------- To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/ Beginner's list: http://groups.yahoo.com/group/ocaml_beginners