Version franaise
Home About Download Resources Contact us
Browse thread
camlp4 compilation model
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Mikkel_Fahnøe_Jørgensen <mikkel@d...>
Subject: camlp4 compilation model
Hi,

I've put camlp4 on the backburner, but I think it is useful to know it
a bit better, especially because several libraries are using it.

a) I understand you can write a cryptic ocaml program that effectively
builds and AST from whatever grammar you decide by applying camlp4.
b) I also understand that camlp4 it has a built in ocaml syntax that
you can extend, and therefore use as camlp4 as a prepreprocessor to
the ocaml compiler as part of the build process.

In a) it makes sense that a library can embed (link with) camlp4 logic
to parse strings without the enduser needing to refer to camlp4 in the
build process.

In b) you would normally require the user to apply the preprocessor to
the source code as part of the build process.

But know my question:

It seems that an enduser program can link with a camlp4 enhanced
library and magically have its syntax extended without adding camlp4
to the build process (once the library has been built). For example
the bitstring library introduces the bitmatch syntax.

Is this correct understood, and how does that work?

One reason I put camlp4 on hold was precisely that added compilation
complexity, but if it can be hidden in a library, it is an entirely
different situation.


Regards,
Mikkel