From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by c5ff346549e7 (Postfix) with ESMTP id A64F55D4 for ; Tue, 3 Mar 2020 13:21:15 +0000 (UTC) X-IronPort-AV: E=Sophos;i="5.70,511,1574118000"; d="scan'208";a="438595646" Received: from sympa.inria.fr ([193.51.193.213]) by mail2-relais-roc.national.inria.fr with ESMTP; 03 Mar 2020 14:21:04 +0100 Received: by sympa.inria.fr (Postfix, from userid 20132) id E49767F449; Tue, 3 Mar 2020 14:21:04 +0100 (CET) Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by sympa.inria.fr (Postfix) with ESMTPS id E5A397F423 for ; Tue, 3 Mar 2020 14:21:01 +0100 (CET) X-IronPort-AV: E=Sophos;i="5.70,511,1574118000"; d="scan'208";a="438595606" Received: from 37-167-75-173.coucou-networks.fr (HELO pl347-pro) ([37.167.75.173]) by mail2-relais-roc.national.inria.fr with ESMTP/TLS/AES256-GCM-SHA384; 03 Mar 2020 14:20:44 +0100 References: User-agent: mu4e 1.1.0; emacs 26.3 From: Thierry Martinez To: caml users In-reply-to: Date: Tue, 03 Mar 2020 14:20:40 +0100 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Caml-list] [ANN] First release of metapp Reply-To: Thierry Martinez X-Loop: caml-list@inria.fr X-Sequence: 18041 Errors-to: caml-list-owner@inria.fr Precedence: list Precedence: bulk Sender: caml-list-request@inria.fr X-no-archive: yes List-Id: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: I wrote=C2=A0: > I am happy to announce the first release of metapp, yet another > preprocessor for OCaml. metapp is available on GitHub: https://github.com/thierry-martinez/metapp and via opam: opam install metapp (metaquot is available on GitHub as well: https://github.com/thierry-martinez/metaquot and via opam: opam install metaquot) Happy hacking! --=20 Thierry. Thierry Martinez=C2=A0: > Dear users of OCaml, > > I am happy to announce the first release of metapp, yet another > preprocessor for OCaml. Similarly to ppx_optcomp, metapp is a PPX > rewriter. But instead of introducing a specific DSL for preprocessor > directives, metapp provides a [%meta ...] extension, where the dots > ... are arbitrary OCaml expressions that are substituted at compile-time > by the AST nodes they evaluate into. These expressions build AST nodes > either by (anti-)quoting some code directly, or by using compiler-libs > (Parsetree, Ast_helper, ...). > > In particular, this preprocessor is easy to use for conditional > compilation, and is an alternative to cppo and ppx_optcomp. > > let option_get o =3D > [%meta if Sys.ocaml_version >=3D "4.08.0" then > [%e Option.get o] > else > [%e match o with > | None -> invalid_arg "option_get" > | Some x -> x]] > > In this example, the code between [%e ... ] is "anti-quoted": it is the > code that is inserted (conditionally) in the rewritten module. Of > course, the anti-quoted code can contain itself some [%meta ...] > code. [%meta ...] can even itself contain other levels of [%meta ...] > code for multi-stage programming. > > An example of usage of metapp is the metaquot package, which implements > the same quoters as ppx_tools.metaquot: [%expr ...], [%type: ...], > etc. These quoters are implemented by meta-programming: the meta-code > introspects Parsetree.cmi from compiler-libs to generate the code > matching the current OCaml version. > > Happy hacking,