* String representation of the expression: may camlp4 help?
@ 2005-08-15 13:51 Dmitri Boulytchev
2005-08-15 20:14 ` [Caml-list] " Martin Jambon
0 siblings, 1 reply; 2+ messages in thread
From: Dmitri Boulytchev @ 2005-08-15 13:51 UTC (permalink / raw)
To: caml-list
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?
Best regards,
Dmitri Boulytchev,
St.Petersburg State University
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [Caml-list] String representation of the expression: may camlp4 help?
2005-08-15 13:51 String representation of the expression: may camlp4 help? Dmitri Boulytchev
@ 2005-08-15 20:14 ` Martin Jambon
0 siblings, 0 replies; 2+ messages in thread
From: Martin Jambon @ 2005-08-15 20:14 UTC (permalink / raw)
To: Dmitri Boulytchev; +Cc: caml-list
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-08-15 20:14 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-15 13:51 String representation of the expression: may camlp4 help? Dmitri Boulytchev
2005-08-15 20:14 ` [Caml-list] " Martin Jambon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox