3 ms·
People have thought of it -- there's probably just not that many applications where sprintf is a bottleneck. Especially enough of a bottleneck to justify a cod
by chubot 12y ago
People have thought of it -- there's probably just not that many applications where sprintf is a bottleneck. Especially enough of a bottleneck to justify a code gen tool.
The OCaml community, and probably others, have noted that printf is an embedded DSL and treat it as something to be compiled rather than interpreted.
http://okmij.org/ftp/typed-formatting/ http://okmij.org/ftp/typed-formatting/
http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.html http://caml.inria.fr/pub/docs/manual-ocaml/libref/Printf.htm... (I have a memory of this being type safe and doing stuff at compile time but I don't see it now)
Rust borrows heavily from OCaml, and uses compile time macros for printf and regex, i.e. format! and regex! (the trailing ! means it's a macro that can be further compiled by the compiler).
http://doc.rust-lang.org/std/fmt/ http://doc.rust-lang.org/std/fmt/
http://doc.rust-lang.org/regex/regex/index.html http://doc.rust-lang.org/regex/regex/index.html