Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
Conditional compilation wrt OCaml version?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2009-01-29 (08:44)
From: Jan Kybic <kybic@f...>
Subject: Ocamlopt+macros, caching MetaOcaml code. Was: Conditional compilation wrt OCaml version?
>>   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:

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
( for this purpose. This works but
combining the way Python and Ocaml syntax is sometimes not very

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?



Jan Kybic <>                       tel. +420 2 2435 5721                      ICQ 200569450