Version française
Home     About     Download     Resources     Contact us    
Browse thread
camlp4 & free variables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe TROESTLER <Christophe.Troestler@u...>
Subject: camlp4 & free variables
Hi,

Is it possible to write a camlp4 syntax extension that "extract" the
free variables of an expression?  As an example, say I write

  FUNCTION(let z = x + 2 in x + 2 * y * x * z)

and it becomes

  fun ~x ~y -> let z = x + 2 in x + 2 * y * x * z

(of course I'd like good error reporting in case of an error in the
expression).  If it is not possible, what is the best way to build a
tool that does that (short of writing a parser for the OCaml language)?

Thanks,
ChriS