formatter(clojure.contrib.pprint)

Macro

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.

; clojure/contrib/pprint/cl-format.clj:1792
(defmacro formatter
  [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#)))))))

Copyright (c) Rich Hickey. All rights reserved.

The use and distribution terms for this software are covered by the Eclipse Public License 1.0, which can be found in the file epl-v10.html at the root of this distribution. By using this software in any fashion, you are agreeing to be bound by the terms of this license. You must not remove this notice, or any other, from this software.