(defmacro formatter
"Makes a function which can directly run format-in. The function is
fn [stream & args] ... and returns nil unless the stream is nil (meaning
output to a string) in which case it returns the resulting string.
format-in can be either a control string or a previously compiled format."
[format-in]
(let [cf (gensym "compiled-format")]
`(let [format-in# ~format-in]
(do (defonce ~cf (if (string? format-in#) (compile-format format-in#) format-in#))
(fn [stream# & args#]
(let [navigator# (init-navigator args#)]
(execute-format stream# ~cf navigator#)))))))
Comments top
No comments for formatter. Log in to add a comment.