Version française
Home     About     Download     Resources     Contact us    
Browse thread
C-like macros in OCaml
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Loup Vaillant <loup.vaillant@g...>
Subject: Re: [Caml-list] C-like macros in OCaml
2007/6/27, Jeremy Yallop <jeremy.yallop@ed.ac.uk>:
> Richard Jones wrote:
> > On Tue, Jun 26, 2007 at 05:00:40PM -0500, Raj B wrote:
> >> Hi there
> >>
> >> Is there any way I can achieve the use of C-like preprocessor macros
> >> in OCaml?
> >> i.e.
> >> [...]
> >[...]
> It appears to support them.  If you have a file `foo.ml' containing the
> following:
> [...]

By the way, does camlp4 handle cross modules C-like macros? If it does, how?
For instance, what if I write, in foo.ml :
DEFINE FOO = 1

and then, in bar.ml :
let bar = FOO;;

or else:
open foo;;
let bar = FOO;;

or even :
let bar = Foo.FOO;;

Will I get what I want?

Now, what about regular quotations? And grammar rules? How can I
specify the scope of particular grammar rule (or quotation)? For the
little I know about camlp4, once defined, the scope of a new grammar
rule is global. (Idem for quotations).

Am I right?
Any clue about the way camlp4 keep track of new grammar rules an
quotations? (Or some pointer to the documentation involved)

Thanks
Loup Vaillant