I can't give much detail from my phone, sorry, but here is a close equivalent I use for debugging:



let debug l format =
let b = Buffer.create 15 in
if l <= !debug_level
then Printf.kbprintf
(fun b -> print_endline (Buffer.contents b))
b format
else
Printf.ifprintf b format


With .mli:

val debug : int -> ('a, Buffer.t, unit, unit) format4 -> 'a


Here I use buffer printers, but you can try to adapt so that it uses string printers (see the difference between sprintf and bprintf). With some callback function you should be able to capture the content of a string or buffer in a lazy value; you might also find ifprintf useful. Hope this helps!

Merry Christmas :)


Francois Berenger <berenger@riken.jp> a écrit :
Hello,

Is is possible to create a sprintf which is lazy?

Especially, I don't know what signature it should have
in the .mli file.

I am fighting with types because the function
is supposed to accept a variable number of parameters
after the format string.
If I manage to create a compilable signature, then
I cannot any-more use a variable number of parameters.

Merry Christmas,
Francois.

--
Simon