caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
* Using camlp4 in extensions
@ 2008-12-15 14:04 Jacques Carette
  2008-12-15 15:24 ` [Caml-list] " Richard Jones
  2008-12-15 22:13 ` Stefano Zacchiroli
  0 siblings, 2 replies; 6+ messages in thread
From: Jacques Carette @ 2008-12-15 14:04 UTC (permalink / raw)
  To: OCaml

Question: is there a way to use a camlp4 extension *inside* the 
definition of another?

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.  Or have I missed something?

Jacques


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Using camlp4 in extensions
  2008-12-15 14:04 Using camlp4 in extensions Jacques Carette
@ 2008-12-15 15:24 ` Richard Jones
  2008-12-15 16:10   ` Mauricio Fernandez
  2008-12-15 22:13 ` Stefano Zacchiroli
  1 sibling, 1 reply; 6+ messages in thread
From: Richard Jones @ 2008-12-15 15:24 UTC (permalink / raw)
  To: Jacques Carette; +Cc: OCaml

On Mon, Dec 15, 2008 at 09:04:34AM -0500, Jacques Carette wrote:
> Question: is there a way to use a camlp4 extension *inside* the 
> definition of another?
> 
> 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.  Or have I missed something?

camlp4 extensions should be composable (as long as they don't actually
conflict with each other).  Just list several *.cmo files on the
camlp4 command line.  What happened when you tried it?

Rich.

-- 
Richard Jones
Red Hat


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Using camlp4 in extensions
  2008-12-15 15:24 ` [Caml-list] " Richard Jones
@ 2008-12-15 16:10   ` Mauricio Fernandez
  2008-12-15 16:15     ` Jacques Carette
  0 siblings, 1 reply; 6+ messages in thread
From: Mauricio Fernandez @ 2008-12-15 16:10 UTC (permalink / raw)
  To: caml-list

On Mon, Dec 15, 2008 at 03:24:47PM +0000, Richard Jones wrote:
> On Mon, Dec 15, 2008 at 09:04:34AM -0500, Jacques Carette wrote:
> > Question: is there a way to use a camlp4 extension *inside* the 
> > definition of another?
> > 
> > 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.  Or have I missed something?
> 
> camlp4 extensions should be composable (as long as they don't actually
> conflict with each other).  Just list several *.cmo files on the
> camlp4 command line.  What happened when you tried it?

I believe he's not referring to simultaneous use of pa_monad and another
extension in user code, but of Camlp4MacroParser *in* the sources of pa_monad.
Since pa_monad is build with

  ocamlc -I +camlp4 -pp camlp4orf -c pa_monad.ml

changing that to 

  ocamlc -I +camlp4 -pp "camlp4orf Camlp4MacroParser.cmo" -c pa_monad.ml

might work.

-- 
Mauricio Fernandez  -   http://eigenclass.org


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Using camlp4 in extensions
  2008-12-15 16:10   ` Mauricio Fernandez
@ 2008-12-15 16:15     ` Jacques Carette
  2008-12-15 16:38       ` blue storm
  0 siblings, 1 reply; 6+ messages in thread
From: Jacques Carette @ 2008-12-15 16:15 UTC (permalink / raw)
  To: caml-list

Mauricio Fernandez wrote:
> I believe he's not referring to simultaneous use of pa_monad and another
> extension in user code, but of Camlp4MacroParser *in* the sources of pa_monad.
>   
That's right.

> Since pa_monad is build with
>
>   ocamlc -I +camlp4 -pp camlp4orf -c pa_monad.ml
>
> changing that to 
>
>   ocamlc -I +camlp4 -pp "camlp4orf Camlp4MacroParser.cmo" -c pa_monad.ml
>
> might work.
>   
Definitely worth exploring, thanks!

Jacques


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Using camlp4 in extensions
  2008-12-15 16:15     ` Jacques Carette
@ 2008-12-15 16:38       ` blue storm
  0 siblings, 0 replies; 6+ messages in thread
From: blue storm @ 2008-12-15 16:38 UTC (permalink / raw)
  To: Jacques Carette; +Cc: caml-list

It might even be possible (though that is a different question, and
looks like much more complicated) to use one's extension inside camlp4
quotations, for example :
<:expr< open Foo in bar >>


On 12/15/08, Jacques Carette <carette@mcmaster.ca> wrote:
> Mauricio Fernandez wrote:
>> I believe he's not referring to simultaneous use of pa_monad and another
>> extension in user code, but of Camlp4MacroParser *in* the sources of
>> pa_monad.
>>
> That's right.
>
>> Since pa_monad is build with
>>
>>   ocamlc -I +camlp4 -pp camlp4orf -c pa_monad.ml
>>
>> changing that to
>>
>>   ocamlc -I +camlp4 -pp "camlp4orf Camlp4MacroParser.cmo" -c pa_monad.ml
>>
>> might work.
>>
> Definitely worth exploring, thanks!
>
> Jacques
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Caml-list] Using camlp4 in extensions
  2008-12-15 14:04 Using camlp4 in extensions Jacques Carette
  2008-12-15 15:24 ` [Caml-list] " Richard Jones
@ 2008-12-15 22:13 ` Stefano Zacchiroli
  1 sibling, 0 replies; 6+ messages in thread
From: Stefano Zacchiroli @ 2008-12-15 22:13 UTC (permalink / raw)
  To: caml-list, OCaml

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.

Cheers.

-- 
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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2008-12-15 22:14 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-12-15 14:04 Using camlp4 in extensions Jacques Carette
2008-12-15 15:24 ` [Caml-list] " Richard Jones
2008-12-15 16:10   ` Mauricio Fernandez
2008-12-15 16:15     ` Jacques Carette
2008-12-15 16:38       ` blue storm
2008-12-15 22:13 ` Stefano Zacchiroli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).