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.1 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 mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 520BCBB84 for ; Thu, 29 Jan 2009 09:44:08 +0100 (CET) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Au4BAOP6gEmTIMAki2dsb2JhbACBbpIkAQEBCgsKGLZBhA4G X-IronPort-AV: E=Sophos;i="4.37,343,1231110000"; d="scan'208";a="22184595" Received: from max.feld.cvut.cz ([147.32.192.36]) by mail3-smtp-sop.national.inria.fr with ESMTP; 29 Jan 2009 09:44:07 +0100 Received: from localhost (unknown [192.168.200.4]) by max.feld.cvut.cz (Postfix) with ESMTP id 30A8619F3699 for ; Thu, 29 Jan 2009 09:44:07 +0100 (CET) X-Virus-Scanned: IMAP AMAVIS Received: from max.feld.cvut.cz ([192.168.200.1]) by localhost (styx.feld.cvut.cz [192.168.200.4]) (amavisd-new, port 10044) with ESMTP id cC457L5QnPnY for ; Thu, 29 Jan 2009 09:44:05 +0100 (CET) Received: from imap.feld.cvut.cz (imap.feld.cvut.cz [147.32.192.34]) by max.feld.cvut.cz (Postfix) with ESMTP id C550C19F3693 for ; Thu, 29 Jan 2009 09:44:05 +0100 (CET) Received: from localhost.fel.cvut.cz (meyer.felk.cvut.cz [147.32.84.20]) by imap.feld.cvut.cz (Postfix) with ESMTPSA id 97B8915C02D for ; Thu, 29 Jan 2009 09:44:05 +0100 (CET) To: caml-list@inria.fr Subject: Ocamlopt+macros, caching MetaOcaml code. Was: Conditional compilation wrt OCaml version? Reply-To: Jan Kybic From: Jan Kybic In-Reply-To: (Sylvain Le Gall's message of "Mon, 26 Jan 2009 21:40:40 +0000 (UTC)") References: <1233005104.20843.25.camel@Blefuscu> Date: Thu, 29 Jan 2009 09:43:58 +0100 Message-ID: <87vdrya4dt.fsf_-_@fel.cvut.cz> User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/22.3 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Spam: no; 0.00; ocamlopt:01 caching:01 metaocaml:01 compilation:01 ocaml:01 compilation:01 ocaml:01 camlp:01 cpp:01 autoconf:01 hackery:01 ocamlopt:01 merging:01 variants:01 compile-time:01 >> Working on Batteries, we're faced with a few places where we'd like to >> perform conditional compilation depending on the version of OCaml being >> used. We could probably do this with Camlp4, cpp, Autoconf hackery, etc. >> -- but first, we need to decide on which of these options we'll adopt. >> > > There is optcomp: > https://forge.ocamlcore.org/projects/optcomp/ > http://darcs.ocamlcore.org/repos/optcomp/optcomp/README > Good morning. I have looked at ocamlopt and it looks very useful. Are there any plans to include macro expansion in ocamlopt? I mean something like merging the functionality of ocamlopt and pa_macro but without the restrictions that pa_macro places on where the macro can be used. Besides conditional compilation - to try different variants of the code or to have debugging messages which can be switched off without any performance penalty - I would also like to use it for short pieces of compile-time generated code (for speed up). Currently, I use a Python-based templating system em.py (http://www.alcyone.com/pyos/empy/) for this purpose. This works but combining the way Python and Ocaml syntax is sometimes not very intuitive. It appears that a modern and universal tool for compile-time code generation is MetaOcaml. However, is there a way in MetaOcaml to generate the code just once and not every time the program is run? I mean, can the code fragments be cached - saved into a file (a shared library?) and later retrieved? Thanks, Jan -- ------------------------------------------------------------------------- Jan Kybic tel. +420 2 2435 5721 http://cmp.felk.cvut.cz/~kybic ICQ 200569450