Hi, Here attached, a proposition of Camlp4 standard syntax extension for macros. The file is named "pa_macro.ml". To compile it do: ocamlc -pp camlp4r -I +camlp4 -c pa_macro.ml To use it for a file "foo.ml", do: To compile: ocamlc -pp "camlp4o ./pa_macro.cmo" foo.ml To just pretty print the resulting source: camlp4o ./pa_macro.cmo pr_o.cmo foo.ml The added statements are indicated in the beginning of the file pa_macro.ml. Keywords uppercase or lowercase? I choosed to write the keywords in uppercase because I consider that they must be visible in the source, just like the "#define" and other "#ifdef" of C are visible, because of the "#" and because of the fact that they are in the first column. And I have considered also that in an expression, it is important to differentiate "ifs" as conditional compilation and normal "ifs". On Thu, Oct 24, 2002 at 03:16:24PM +0200, Basile STARYNKEVITCH wrote: > #ifdef WANT_DEBUG > #define DEBUGME(V) if (debugflag) printf("%d", V) > #else > #define DEBUGME(V) {} > #endif With pa_macro.cmo, you can write it like this: IFDEF WANT_DEBUG THEN DEFINE DEBUGME(v) = if (debugflag) then printf("%d", v) ELSE DEFINE DEBUGME(v) = () END To define "WANT_DEBUG" you can either insert in the source: DEFINE DEBUGME Or add "-DWANT_DEBUG" as option: camlp4o ./pa_macros.cmo pr_o.cmo -DWANT_DEBUG foo.ml ocamlc -pp "camlp4o ./pa_macros.cmo -DWANT_DEBUG" foo.ml > 5. having the equivalent of __FILE__ and __LINE__ is very useful Ok file __FILE__. For __LINE__, it is complicated. I added __LOCATION__. Any comments? -- Daniel de RAUGLAUDRE http://cristal.inria.fr/~ddr/