English version
Accueil     À propos     Téléchargement     Ressources     Contactez-nous    

Ce site est rarement mis à jour. Pour les informations les plus récentes, rendez-vous sur le nouveau site OCaml à l'adresse ocaml.org.

Browse thread
Using camlp4 in extensions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2008-12-15 (22:14)
From: Stefano Zacchiroli <zack@u...>
Subject: Re: [Caml-list] Using camlp4 in extensions
On Mon, Dec 15, 2008 at 09:04:34AM -0500, Jacques Carette wrote:
> AFAIK, extensions are not ordered, so trying to use camlp4 to deal
> with IFDEF in the source of a syntax extension (like pa_monad) to
> switch between 3.10 and 3.11 [to deal with the new private and lazy
> features] does not seem possible.

Why so?

When you build a camlp4 extension you're compiling some code relying
on camlp4 _as a library_. The code you're actually compiling is
compiled by the ocaml compiler, which can possibly receive it from
whatever pre-processor. That pre-processor can of course be camlp4
itself, loading some other camlp4 extension.

In short:

  ocamlc -pp "camlp4o available_ext.cmo" -c new_ext.ml

should work.

Of course, as observed, you can have grammar conflicts between the two
extensions, but that's an entirely different problem.


Stefano Zacchiroli -o- PhD in Computer Science \ PostDoc @ Univ. Paris 7
zack@{upsilon.cc,pps.jussieu.fr,debian.org} -<>- http://upsilon.cc/zack/
Dietro un grande uomo c'è ..|  .  |. Et ne m'en veux pas si je te tutoie
sempre uno zaino ...........| ..: |.... Je dis tu à tous ceux que j'aime