Commits

camlspotter committed c174cc4

better sprintf

  • Participants
  • Parent commits 5dacc68

Comments (0)

Files changed (2)

File lib/xformat.ml

 let lazy_ p ppf v =
   if Xlazy.is_val v then p ppf (Xlazy.(!!) v)
   else Format.fprintf ppf "lazy"
+
+let sprintf fmt =
+  let buf = Buffer.create 100 in
+  let ppf = formatter_of_buffer buf in
+  kfprintf (fun ppf -> flush ppf; Buffer.contents buf) ppf fmt

File lib/xformat.mli

   (int -> unit)
 val set_formatter_tag_functions : t -> formatter_tag_functions -> unit
 val formatter_tag_functions : t -> unit -> formatter_tag_functions
+
+val sprintf : ('a, t, unit, string) format4 -> 'a
+  (** [sprintf] with a better type than the orignal *)