UnixJunkie / dolog

A dumb OCaml logger
Other
37 stars 7 forks source link

make printf-like functions lazy too #13

Closed UnixJunkie closed 9 years ago

UnixJunkie commented 9 years ago

Cf. https://groups.google.com/forum/#!topic/fa.caml/fOfJVpHywW0 text from Gabriel Scherer:

let delayed_sprintf fmt = Printf.sprintf (fmt ^^ "%s");;
# let result = Printf.sprintf "%d) %s\n" 3 "foo";;
val result : string = "3) foo\n"
# let thunk = delayed_sprintf "%d) %s\n" 3 "foo";;
val thunk : string -> string = <fun>
# thunk "";;
- : string = "3) foo\n" 
UnixJunkie commented 9 years ago

done