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
camlp4 & free variables
[ Home ] [ Index: by date | by threads ]
[ Search: ]

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

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