1.2.0 permalink Arrow_down_16x16

execute-format

clojure.contrib.pprint

  • (execute-format stream format args)
  • (execute-format format args)
Executes the format with the arguments. This should never be used directly, but is public
because the formatter macro uses it.

0 Examples top

Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/contrib/pprint/cl_format.clj:1783 top

(defn execute-format 
  "Executes the format with the arguments. This should never be used directly, but is public
because the formatter macro uses it."
  {:skip-wiki true}
  ([stream format args]
     (let [^java.io.Writer real-stream (cond 
                                         (not stream) (java.io.StringWriter.)
                                         (true? stream) *out*
                                         :else stream)
           ^java.io.Writer wrapped-stream (if (and (needs-pretty format) 
                                                    (not (pretty-writer? real-stream)))
                                             (get-pretty-writer real-stream)
                                             real-stream)]
       (binding [*out* wrapped-stream]
         (try
          (execute-format format args)
          (finally
           (if-not (identical? real-stream wrapped-stream)
             (.flush wrapped-stream))))
         (if (not stream) (.toString real-stream)))))
  ([format args]
     (map-passing-context 
      (fn [element context]
        (if (abort? context)
          [nil context]
          (let [[params args] (realize-parameter-list 
                               (:params element) context)
                [params offsets] (unzip-map params)
                params (assoc params :base-args args)]
            [nil (apply (:func element) [params args offsets])])))
      args
      format)))
Vars in clojure.contrib.pprint/execute-format: binding defn fn format identical? if-not let not

Comments top

No comments for execute-format. Log in to add a comment.