I'm using the following function to have pprint write into a string and limit 
the output:


(defn pprint-str
  "Return string with pprint of v, and limit output to prevent blowup."
  [v]
  (with-out-str (binding [*print-length* 32 *print-level* 6] (pprint v))))


Everything seems to work as expected, except when trying to print a var value 
of nil:


user=> (pprint #'clojure.core/*print-length*)
#<Var@5d2aea3e: nil>
nil
user=> (clj-ns-browser.utils/pprint-str #'clojure.core/*print-length*)
"#<Var@5d2aea3e: 32>\n"
user=> (with-out-str (binding [*print-length* 32 *print-level* 6] (pprint 
#'clojure.core/*print-length*)))
"#<Var@5d2aea3e: 32>\n"
user=> (binding [*print-length* 32 *print-level* 6] (pprint 
#'clojure.core/*print-length*))#<Var@5d2aea3e: 32>
nil
user=> (binding [*print-length* 33 *print-level* 6] (pprint 
#'clojure.core/*print-length*))
#<Var@5d2aea3e: 33>
nil
user=> 


It seems that the *print-length* binding-value is printed out when the 
var-value is nil.

Bug?
Feature?
Should I have used binding in a different way?

Thanks, FrankS.



-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en

Reply via email to