Version française
Home     About     Download     Resources     Contact us    
Browse thread
[Caml-list] embedding OCaml into C on win32
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Daniel de Rauglaudre <daniel.de_rauglaudre@i...>
Subject: Re: [Caml-list] camlp4 and anonymous function naming
Hi,

On Tue, Jul 02, 2002 at 04:48:22PM -0400, Julie Farago wrote:

> let givenames loc vars e =
>   let name = namefun "my" in
>     <:expr<
>       let $lid:name$ $vars$ = $e$
>       in $lid:name$ >>
> 
> This code is, of course, wrong. The problem is that I cannot figure out
> how to simply capture the args from the fun and place them back into the
> let.

Write this function like this:

let givenames loc vars e =
  let name = namefun "my" in
  let e =
    List.fold_right (fun p e -> <:expr< fun $lid:p$ -> $e$ >>) vars e
  in
    <:expr<
      let $lid:name$ = $e$
      in $lid:name$ >>

-- 
Daniel de RAUGLAUDRE
daniel.de_rauglaudre@inria.fr
http://cristal.inria.fr/~ddr/
-------------------
To unsubscribe, mail caml-list-request@inria.fr Archives: http://caml.inria.fr
Bug reports: http://caml.inria.fr/bin/caml-bugs FAQ: http://caml.inria.fr/FAQ/
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners