Version française
Home     About     Download     Resources     Contact us    
Browse thread
Immediate recursive functions
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Alex Baretta <alex@b...>
Subject: Re: [Caml-list] Camlp4 with traditional syntax (was: Camlp4 documentation)
Hendrik Tews wrote:
> Alex Baretta <alex@barettadeit.com> writes:
> 
>    There is one more issue with Camlp4: it does not allow for quotations
>    to expand to generic syntactic elements. Often, I use quotations which
>    expand to module definitions. I had to implement my own quotation
>    expander, bypassing the limitations of Camlp4 to achieve this.
>    
> I don't quite understand, what's wrong with 
> 
> let me = <:module_expr< struct $ list of module def's $ end >>
> in
>   <:str_item< module $some_name$ = $me$ >> 

We use quotation expanders to embed completely different languages, such 
as SQL, within Ocaml code. Specifically, the SQL quotation expander 
compiles SQL code to an Ocaml module. CamlP4 signals an error because 
quotations are only meant to be used as expressions or as patterns, 
IIRC. Anyhow, the solution is either to use ocpp rather than camlp4 as a 
preprocessor (ocpp is less picky), or to write one's own quotation 
preprocessor. We use both techniques depending on the context.

Alex


-- 
*********************************************************************
http://www.barettadeit.com/
Baretta DE&IT
A division of Baretta SRL

tel. +39 02 370 111 55
fax. +39 02 370 111 54

Our technology:

The Application System/Xcaml (AS/Xcaml)
<http://www.asxcaml.org/>

The FreerP Project
<http://www.freerp.org/>