Version française
Home     About     Download     Resources     Contact us    
Browse thread
String representation of the expression: may camlp4 help?
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Martin Jambon <martin_jambon@e...>
Subject: Re: [Caml-list] String representation of the expression: may camlp4 help?
On Mon, 15 Aug 2005, Dmitri Boulytchev wrote:

>   Hello everybody,
>
>   I'm looking for the way to get string representation of the OCaml 
> expression
>   at compile-time to facilitate test writing. Consider an example:
>
>        let repr, value = WITH_REPR (1+2) in
>        Printf.printf "%s=%d" repr value
>
>   Here WITH_REPR is a meta-construction that returns ("1+2", 3) (generally
>   speaking WITH_REPR(c) whould return (string * type_of c)).
>
>   Is there some convinient way to do this? May camlp4 help?

Have a look at the pretty-printing functions that pr_o.ml 
provides (from your Camlp4 installation). You can probably hack your own 
(expr -> string) function if it does not already exist.


Martin

--
Martin Jambon, PhD
http://martin.jambon.free.fr