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
A macro system compatible with modules
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2007-06-20 (12:17)
From: Loup Vaillant <loup.vaillant@g...>
Subject: A macro system compatible with modules

I would like to define a macro system (like #define) which satisfy the
following constraints :

-> When I define a macro, it is available for use right now, in the
same compilation unit.
-> If I want to call the macro from another compilation unit, I just
have to either open the corresponding module :

open My_comp_unit;;
(* some code *)
my_macro (* macro arguments *)

or access the macro through indirection :

My_comp_unit.my_macro (* macro arguments *)

-> [optional] a macro must declared in the .mli file to be accessible
from the outside, and is automatically accessible if this .mli file is
not defined by the author of the compilation unit.
-> [optional] do the same things for any module (defined as is, or
from a functor)

This would be ideal for avoiding namespaces issues.

What about plain camlp4 macros?
What about the #define defined in camlp4?
Is such a a thing possible?
To what extent?

Loup Vaillant

  my ultimate goal is Lisp-like macros)