<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
<channel>
<title>Clojure Q&amp;A - Recent questions in Printing</title>
<link>https://ask.clojure.org/index.php/questions/clojure/printing</link>
<description></description>
<item>
<title>error printed using pprint in clojure 1.13.0-alpha1</title>
<link>https://ask.clojure.org/index.php/15153/error-printed-using-pprint-in-clojure-1-13-0-alpha1</link>
<description>&lt;pre&gt;&lt;code&gt;❯ clj -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.13.0-alpha1&quot;}}}'
Clojure 1.13.0-alpha1
user=&amp;gt; (clojure.pprint/pprint :foo)
Execution error (ClassCastException) at clojure.pprint.proxy$java.io.Writer$IDeref$PrettyFlush$4923d848/flush (REPL:-1).
class clojure.pprint.proxy$java.io.Writer$IDeref$PrettyFlush$4923d848 cannot be cast to class clojure.pprint.PrettyFlush (clojure.pprint.proxy$java.io.Writer$IDeref$PrettyFlush$4923d848 is in unnamed module of loader 'app'; clojure.pprint.PrettyFlush is in unnamed module of loader clojure.lang.DynamicClassLoader @36a58466)
:foo
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;reported by djblue in #clojure-dev&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/15153/error-printed-using-pprint-in-clojure-1-13-0-alpha1</guid>
<pubDate>Thu, 02 Jul 2026 20:22:36 +0000</pubDate>
</item>
<item>
<title>clojure.pprint/pprint converts unquote+deref to unquote-splicing</title>
<link>https://ask.clojure.org/index.php/14053/clojure-pprint-pprint-converts-unquote-deref-unquote-splicing</link>
<description>&lt;p&gt;This is very unusual syntax but pretty-printing it does not round-trip.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;$ clj -Sforce -Sdeps '{:deps {org.clojure/clojure {:mvn/version &quot;1.11.4&quot;}}}'
Clojure 1.11.4
user=&amp;gt; (require '[clojure.pprint :as pp])
nil
user=&amp;gt; (-&amp;gt; &quot;~ @a&quot; read-string pp/pprint)
~@a
nil
user=&amp;gt; (-&amp;gt; '~ @a)
(clojure.core/unquote (clojure.core/deref a))
user=&amp;gt; (-&amp;gt; '~ @a pp/pprint with-out-str read-string)
(clojure.core/unquote-splicing a)
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14053/clojure-pprint-pprint-converts-unquote-deref-unquote-splicing</guid>
<pubDate>Mon, 12 Aug 2024 23:25:23 +0000</pubDate>
</item>
<item>
<title>Why does clojure.core/newline not respect *flush-on-newline*?</title>
<link>https://ask.clojure.org/index.php/14044/why-does-clojure-core-newline-not-respect-flush-on-newline</link>
<description>&lt;p&gt;Calling &lt;code&gt;(newline)&lt;/code&gt; appends a newline to the output stream but does not flush it &lt;code&gt;*flush-on-newline*&lt;/code&gt; is bound to &lt;code&gt;true&lt;/code&gt; (the default).&lt;/p&gt;
&lt;p&gt;Instead, only &lt;code&gt;clojure.core/prn&lt;/code&gt; mentions &lt;code&gt;*flush-on-newline*&lt;/code&gt; in its docstring and the check and &lt;code&gt;(flush)&lt;/code&gt; call is explicit there.&lt;/p&gt;
&lt;p&gt;Why is this?&lt;/p&gt;
&lt;p&gt;Also, &lt;code&gt;println&lt;/code&gt; does not mention that it &lt;code&gt;Observes *flush-on-newline*&lt;/code&gt; like &lt;code&gt;prn&lt;/code&gt; does, and it doesn't hint that it calls &lt;code&gt;prn&lt;/code&gt; which does, since it says &lt;code&gt;Same as print followed by (newline)&lt;/code&gt; which isn't actually true.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/14044/why-does-clojure-core-newline-not-respect-flush-on-newline</guid>
<pubDate>Wed, 07 Aug 2024 23:09:06 +0000</pubDate>
</item>
<item>
<title>inst changes old dates in Clojure 1.12 alpha10</title>
<link>https://ask.clojure.org/index.php/13854/inst-changes-old-dates-in-clojure-1-12-alpha10</link>
<description>&lt;p&gt;UPDATE:&lt;/p&gt;
&lt;p&gt;&lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.org/news/2024/05/23/clojure-1-12-alpha12&quot;&gt;https://clojure.org/news/2024/05/23/clojure-1-12-alpha12&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Alpha12 reverted the change that caused this issue.  This discussion is therefore obsolete.&lt;/p&gt;
&lt;hr&gt;
&lt;p&gt;I just noticed that Clojure 1.12 alpha10 has changed the way old #inst dates are created.  As far as I can tell, Java is trying to adjust old dates before the Gregorian calendar was introduced.&lt;/p&gt;
&lt;p&gt;In Clojure 1.11.3&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user-&amp;gt; #inst &quot;1582-02-24&quot;
#inst &quot;1582-02-24T00:00:00.000-00:00&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In Clojure 1.12-alpha10&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; #inst &quot;1582-02-24&quot;
#inst &quot;1582-03-06T00:00:00.000-00:00&quot;
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I found this when I ran some generative tests on an old project that tested dates.  I'm changing my tests to look only at this millennium, which is fine for my application.  I don't think Clojure should necessarily do anything to mitigate this change.  I just thought it was worth a mention in case someone else bumps into it.&lt;/p&gt;
&lt;p&gt;Updated to Clojure 1.12 alpha 11:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user=&amp;gt; (use 'clojure.instant)
nil
user=&amp;gt; (read-instant-date &quot;1582-02-24&quot;)
#inst &quot;1582-03-06T00:00:00.000-00:00&quot;
user=&amp;gt; (read-instant-calendar &quot;1582-02-24&quot;)
#inst &quot;1582-02-24T00:00:00.000+00:00&quot;
user=&amp;gt; (read-instant-timestamp &quot;1582-02-24&quot;)
#inst &quot;1582-03-06T00:00:00.000000000-00:00&quot;
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13854/inst-changes-old-dates-in-clojure-1-12-alpha10</guid>
<pubDate>Sun, 28 Apr 2024 21:29:36 +0000</pubDate>
</item>
<item>
<title>is '(CID (pr-str my-map)) unambiguously defined?</title>
<link>https://ask.clojure.org/index.php/13685/is-cid-pr-str-my-map-unambiguously-defined</link>
<description>&lt;p&gt;is a serial representation of a clojure map unambiguously defined? if i compute CID of 'pr-str' of a clojure map, is it unique?&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13685/is-cid-pr-str-my-map-unambiguously-defined</guid>
<pubDate>Sun, 11 Feb 2024 18:27:28 +0000</pubDate>
</item>
<item>
<title>clojure.pprint/pprint bug when using the code-dispatch table</title>
<link>https://ask.clojure.org/index.php/13455/clojure-pprint-pprint-bug-when-using-the-code-dispatch-table</link>
<description>&lt;p&gt;There seams to be a bug in clojure.pprint/pprint when using the code-dispatch table  and printing let. It happens on Clojure and ClojureScript.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.11.1
user=&amp;gt; (require '[clojure.pprint :as pp])

user=&amp;gt; 
(binding [pp/*print-pprint-dispatch* pp/code-dispatch]
  (pp/pprint
   '(let)))

((let)) ;; prints some extra parenthesis

(binding [pp/*print-pprint-dispatch* pp/code-dispatch]
  (pp/pprint
   '(let*)))

(let*) ;; doesn't happen when pprinting any other form
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13455/clojure-pprint-pprint-bug-when-using-the-code-dispatch-table</guid>
<pubDate>Fri, 10 Nov 2023 14:06:05 +0000</pubDate>
</item>
<item>
<title>print-method is inconsistent with regard to clojure.pprint with *print-level*</title>
<link>https://ask.clojure.org/index.php/13337/print-method-inconsistent-regard-clojure-pprint-print-level</link>
<description>&lt;p&gt;Repro:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;;; print-method

user=&amp;gt; (binding [*print-level* 1]
         (prn {:a 1 :b 2}))
{:a 1, :b 2}
nil

user=&amp;gt; (binding [*print-level* 1]
         (prn {:a {:b 2}}))
{:a #}
nil

user=&amp;gt; (binding [*print-level* 1]
         (prn [(clojure.lang.MapEntry. :a 1)
               (clojure.lang.MapEntry. :b 2)]))
[# #]
nil

;; clojure.pprint

user=&amp;gt; (binding [*print-level* 1]
         (clojure.pprint/pprint {:a 1 :b 2}))
{#, #}
nil

user=&amp;gt; (binding [*print-level* 1]
         (clojure.pprint/pprint {:a {:b 2}}))
{#}
nil

user=&amp;gt; (binding [*print-level* 1]
         (clojure.pprint/pprint
           [(clojure.lang.MapEntry. :a 1)
            (clojure.lang.MapEntry. :b 1)]))
[# #]
nil
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The docstring for &lt;code&gt;*print-level*&lt;/code&gt; says:&lt;/p&gt;
&lt;blockquote&gt;&lt;p&gt;If an object is a collection and is at a level greater than or equal to the value bound to &lt;em&gt;print-level&lt;/em&gt;, the printer prints '#' to represent it.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;A map entry is a collection and in &lt;code&gt;{:a 1, :b 2}&lt;/code&gt; is at a level equal to &lt;code&gt;*print-level*&lt;/code&gt;, so I would expect &lt;code&gt;prn&lt;/code&gt; to have the same output as &lt;code&gt;clojure.pprint&lt;/code&gt;.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13337/print-method-inconsistent-regard-clojure-pprint-print-level</guid>
<pubDate>Thu, 28 Sep 2023 07:02:04 +0000</pubDate>
</item>
<item>
<title>#inst printer uses a ThreadLocal SimpleDateFormat, which is inefficient with virtual threads</title>
<link>https://ask.clojure.org/index.php/13333/printer-threadlocal-simpledateformat-inefficient-virtual</link>
<description>&lt;p&gt;The #inst printer uses java.text.SimpleDateFormat, which is not thread-safe. As per common Java practice (of yesteryear), the instance used is folded into a proxied ThreadLocal so all access per thread is thread-safe but no synchronization is needed. In Java 21, this is not ideal because virtual threads are numerous and there is little reuse within a single virtual thread, as there would have been before in a pooled non-virtual thread.&lt;/p&gt;
&lt;p&gt;Instead, we should use the immutable formatter provided since Java 8 in java.time.format.DateTimeFormatter and not use a ThreadLocal for this.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13333/printer-threadlocal-simpledateformat-inefficient-virtual</guid>
<pubDate>Tue, 26 Sep 2023 21:11:41 +0000</pubDate>
</item>
<item>
<title>problem with Null exception in cl-format</title>
<link>https://ask.clojure.org/index.php/13162/problem-with-null-exception-in-cl-format</link>
<description>&lt;p&gt;If the format string ends in ~@, there is code in cl-format to detect this&lt;br&gt;
and issue a format-error.  However, that error detection is wrong, and a null exception&lt;br&gt;
happens rather than the format-error being reported.&lt;/p&gt;
&lt;p&gt;To reproduce this, simply evaluate the following.&lt;/p&gt;
&lt;p&gt;clojure.pprint&amp;gt; (cl-format false &quot;~@&quot;)&lt;br&gt;
Execution error (NullPointerException) at nrepl.middleware.interruptible-eval/evaluate$fn$fn (interruptible_eval.clj:87).&lt;/p&gt;
&lt;p&gt;I have a fix for this which I'd like to contribute.&lt;/p&gt;
&lt;p&gt;Here is the new version of the code &lt;code&gt;compile-directive&lt;/code&gt;&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(defn- compile-directive [s offset]
  (let [[raw-params [rest offset]] (extract-params s offset)
        [_ [rest offset flags]] (extract-flags rest offset)
        directive (first rest)
        ;; previous version was missing (if directive ...) here thus (format-error ...) never reached
        def (if directive (get directive-table (Character/toUpperCase ^Character directive)))
        params (if def (map-params def (map translate-param raw-params) flags offset))]
    (if (not directive)
      (format-error &quot;Format string ended in the middle of a directive&quot; offset))
    (if (not def)
      (format-error (str &quot;Directive \&quot;&quot; directive &quot;\&quot; is undefined&quot;) offset))
    [(struct compiled-directive ((:generator-fn def) params offset) def params offset)
     (let [remainder (subs rest 1) 
           offset (inc offset)
           trim? (and (= \newline (:directive def))
                      (not (:colon params)))
           trim-count (if trim? (prefix-count remainder [\space \tab]) 0)
           remainder (subs remainder trim-count)
           offset (+ offset trim-count)]
       [remainder offset])]))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The old version&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/13162/problem-with-null-exception-in-cl-format</guid>
<pubDate>Wed, 16 Aug 2023 14:36:19 +0000</pubDate>
</item>
<item>
<title>Potential issue in ~:[ directive in cl-format.</title>
<link>https://ask.clojure.org/index.php/12513/potential-issue-in-directive-in-cl-format</link>
<description>&lt;p&gt;I am using the cl-format function from the clojure.pprint library. I am using the ~:[ directive as follows:&lt;/p&gt;
&lt;p&gt;(cl-format nil &quot;~:[~;~a~]&quot; arg)&lt;/p&gt;
&lt;p&gt;When arg is nil, I get the expected empty string as a return value. However, when arg is non-nil, liike 1, I get an error: &quot;Not enough arguments for format definition.&quot; When I pass a second arg to the cl-format function:&lt;/p&gt;
&lt;p&gt;(cl-format nil &quot;~:[~;~a~]&quot; 1 2)&lt;/p&gt;
&lt;p&gt;it prints 2, so it's acting as if it is absorbing the first argument to check for its non-nil character and then passing the second to the internal format directive.&lt;/p&gt;
&lt;p&gt;From my reading of both the CL Hyperspec, and the gigamonkies format reference, the ~:[ should not absorb the argument but pass it on to the internal spec for printing. Is this an error in the implementation of cl-format or am I misinterpreting the spec?&lt;/p&gt;
&lt;p&gt;I've looked at the source and it sure looks like the navigator argument to execute-sub-format on line 862 of &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/cl_format.clj&quot;&gt;https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/cl_format.clj&lt;/a&gt; should be arg-navigator instead.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/12513/potential-issue-in-directive-in-cl-format</guid>
<pubDate>Thu, 29 Dec 2022 14:30:48 +0000</pubDate>
</item>
<item>
<title>printing and reading date types</title>
<link>https://ask.clojure.org/index.php/11898/printing-and-reading-date-types</link>
<description>&lt;p&gt;To my understanding, Clojure's &lt;code&gt;pr&lt;/code&gt; function prints objects so that when read back will be &lt;code&gt;=&lt;/code&gt; to the original object. My main source for this come s from this talk &lt;a rel=&quot;nofollow&quot; href=&quot;https://youtu.be/pbodL96HM28?t=216&quot;&gt;https://youtu.be/pbodL96HM28?t=216&lt;/a&gt; from Clojure core developer Stuart Sierra ( I cannot find any docs to say what guarantees pr offers).&lt;/p&gt;
&lt;p&gt;If this is correct, then &lt;code&gt;pr&lt;/code&gt; is not working for java.sql.Timestamp and java.util.Calendar. For example, this returns false.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(let [d (java.sql.Timestamp. 1)]
(= d
(read-string
  (pr-str d))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Further, Clojure's documentation says , &lt;em&gt;print-dup&lt;/em&gt;, when true, means that &lt;code&gt;objects will be printed in a way that preserves their type when read in later&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is not the case for java.sql.Timestamp and java.util.Calendar&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(binding [*print-dup* true]&lt;br&gt;
  (prn (java.sql.Timestamp. 1)))&lt;br&gt;
=&amp;gt;  #inst &quot;1970-01-01T00:00:00.001000000-00:00&quot;&lt;/p&gt;
&lt;p&gt;As well as being interesting to get some answers to the above, understanding these issues might give some basis for Clojure's support of java.time date types as tracked by &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.atlassian.net/browse/CLJ-2224&quot;&gt;https://clojure.atlassian.net/browse/CLJ-2224&lt;/a&gt; .&lt;/p&gt;
&lt;p&gt;I understand the above behaviour can be changed by users, but I am asking about the default implementations.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11898/printing-and-reading-date-types</guid>
<pubDate>Fri, 20 May 2022 05:31:02 +0000</pubDate>
</item>
<item>
<title>print-table config opts</title>
<link>https://ask.clojure.org/index.php/11886/print-table-config-opts</link>
<description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;I find when cell-content widths vary a lot (e.g. in some col, some long strings and some short) that the current right-aligned output is hard to read. &lt;/p&gt;
&lt;p&gt;can print-table have opt to left-align output?  &lt;/p&gt;
&lt;p&gt;Also, I often want to copy output from print-table into a spreadsheet. left-aligning would help (trimming not a one-click thing in spreadsheets afaik), but what might actually help even more is to have e.g. a csv output (so no whitespace padding happens) at all. I can reach for csv lib ofc, but the use case of 'get some clojure data into spreadsheet' is something I might want anywhere anytime, so in the same way that vi editor comes as standard with many linux distros mostly, this would be handy to have.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11886/print-table-config-opts</guid>
<pubDate>Thu, 12 May 2022 11:46:04 +0000</pubDate>
</item>
<item>
<title>Is there a way to tell pprint to start with an initial indentation, so that the whole output is indented?</title>
<link>https://ask.clojure.org/index.php/11796/there-pprint-start-initial-indentation-whole-output-indented</link>
<description>&lt;p&gt;I'd like to pprint a data structure, where the whole thing is printed indented.  (As if, for example, I was already some levels deep).&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;(pprint x)
{:foo ...
 :bar ...}

(pprint-with-indentation x)
    {:foo ...
     :bar ...}
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I tried calling &lt;code&gt;pprint-indent&lt;/code&gt; before &lt;code&gt;pprint&lt;/code&gt;, but that didn't work (or I was using it wrong!)&lt;/p&gt;
&lt;p&gt;Stel commented with a solution of adding the indentation after running pprint.  This would certainly work; I was looking more specifically to ask if there was a way to get pprint to do it (so that the output would continue to conform to &lt;code&gt;*print-right-margin*&lt;/code&gt; etc. without adjusting the margins myself).  Of course, if there isn't a way to do that, Stel's solution is a good workaround.&lt;/p&gt;
&lt;p&gt;Any ideas of what I could try?&lt;/p&gt;
&lt;p&gt;Thanks!&lt;/p&gt;
&lt;p&gt;Andrew&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11796/there-pprint-start-initial-indentation-whole-output-indented</guid>
<pubDate>Sat, 23 Apr 2022 21:18:00 +0000</pubDate>
</item>
<item>
<title>Why Clojure's println does not print Unicode chars properly, while Java's println does?</title>
<link>https://ask.clojure.org/index.php/11309/clojures-println-print-unicode-chars-properly-while-println</link>
<description>&lt;p&gt;The repro is very simple, note the correct &lt;code&gt;║&lt;/code&gt; with Java's &lt;code&gt;println&lt;/code&gt; and incorrect &lt;code&gt;?&lt;/code&gt; with Clojure's &lt;code&gt;println&lt;/code&gt;:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;Clojure 1.10.3
user=&amp;gt; (.println System/out &quot;abc\u2551&quot;)
abc║
nil
user=&amp;gt; (println &quot;abc\u2551&quot;)
abc?
nil
&lt;/code&gt;&lt;/pre&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/11309/clojures-println-print-unicode-chars-properly-while-println</guid>
<pubDate>Wed, 24 Nov 2021 07:53:26 +0000</pubDate>
</item>
<item>
<title>Should pr-str on a function produce valid edn syntax?</title>
<link>https://ask.clojure.org/index.php/10278/should-pr-str-on-a-function-produce-valid-edn-syntax</link>
<description>&lt;p&gt;Is the &lt;code&gt;print-method&lt;/code&gt; implementation for functions intended to produce valid &lt;code&gt;edn&lt;/code&gt; syntax? In some cases, it does not:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (require '[org.httpkit.server :as http])
user&amp;gt; (def s (http/run-server (fn [req] {:status 200}) {}))
user&amp;gt; (prn s)
#function[clojure.lang.AFunction/1]
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Symbol names can't start with a number, so &lt;code&gt;clojure.lang.AFunction/1&lt;/code&gt; causes a parse error when read back:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;user&amp;gt; (clojure.edn/read-string (prn-str s))
Execution error at user/eval7394 (REPL:68).
Invalid token: clojure.lang.AFunction/1
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Is this the expected behavior? If so, printing and re-reading data structures that may contain fns can fail.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/10278/should-pr-str-on-a-function-produce-valid-edn-syntax</guid>
<pubDate>Wed, 03 Mar 2021 03:28:04 +0000</pubDate>
</item>
<item>
<title>Can clojure.core/system-newline be made public?</title>
<link>https://ask.clojure.org/index.php/9473/can-clojure-core-system-newline-be-made-public</link>
<description>&lt;p&gt;Right now, &lt;code&gt;newline&lt;/code&gt; accesses a &lt;strong&gt;private&lt;/strong&gt; var named &lt;code&gt;system-newline&lt;/code&gt; which is initialized from the Java system property &lt;code&gt;line.separator&lt;/code&gt;. For portability reasons, it would be nice if Clojure made this variable public so that application code could easily access it. Is there any reason to keep it private?&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/9473/can-clojure-core-system-newline-be-made-public</guid>
<pubDate>Thu, 16 Jul 2020 19:05:21 +0000</pubDate>
</item>
<item>
<title>pr botches structmaps containing namespaced keys when *print-namespace-maps*</title>
<link>https://ask.clojure.org/index.php/4245/botches-structmaps-containing-namespaced-print-namespace</link>
<description>{{pr}} misrepresents a structmap containing namespaced-keyword keys. &amp;nbsp;{{pr}} misstates actual keys' values, and includes phantom keys.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (pr-str (struct (create-struct :q/a :q/b :q/c) 1 2 3))&lt;br /&gt;
&amp;quot;#:q{:q/a nil, :q/b nil, :q/c nil, :c 3, :b 2, :a 1}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
It worked in Clojure 1.8, and disabling the print-namespace-maps feature appears to work around the problem:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (binding [*print-namespace-maps* false] &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(pr-str (struct (create-struct :q/a :q/b :q/c) 1 2 3)))&lt;br /&gt;
&amp;quot;{:q/a 1, :q/b 2, :q/c 3}&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
By the way: Structmaps are (now as ever) appropriate when the basis is anonymous and computed (not coded) or key order is a significant aspect of the basis. &amp;nbsp;People sometimes cite the reference doc's statement, &amp;quot;Most uses of StructMaps would now be better served by records&amp;quot;, but, of course, it is referring only to those uses that are _actually_ better served by records. &amp;nbsp;Record classes can't be anonymous and defrecord needs the basis at compile time; and normal maps do not exhibit a preset key order. &amp;nbsp;Thus the continuing relevance of structmaps.</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4245/botches-structmaps-containing-namespaced-print-namespace</guid>
<pubDate>Mon, 21 Jan 2019 03:41:30 +0000</pubDate>
</item>
<item>
<title>Add support for ~/ directive in cl-format</title>
<link>https://ask.clojure.org/index.php/2822/add-support-for-directive-in-cl-format</link>
<description>&lt;p&gt;clojure.pprint/cl-format does not support the ~/ directive which allows to extend the formatter with custom functions.&lt;/p&gt;
&lt;p&gt;The doc at &lt;a rel=&quot;nofollow&quot; href=&quot;https://clojure.github.io/clojure/doc/clojure/pprint/CommonLispFormat.html&quot;&gt;https://clojure.github.io/clojure/doc/clojure/pprint/CommonLispFormat.html&lt;/a&gt; mentions that support for ~/ is next up.&lt;/p&gt;
&lt;p&gt;This Jira is to ask if someone is willing to contribute that enhancement to it.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2822/add-support-for-directive-in-cl-format</guid>
<pubDate>Thu, 09 Aug 2018 09:07:50 +0000</pubDate>
</item>
<item>
<title>'Exception Not enough arguments for format definition' deep inside pprint</title>
<link>https://ask.clojure.org/index.php/2820/exception-enough-arguments-format-definition-inside-pprint</link>
<description>&lt;p&gt;My first time submitting a bug.  I didn't understand Jira very well; it asked me which project and I couldn't figure out the right project (I assumed ClojureCLR because the pprint issues seem to be tagged 'CLR', but I don't know if ClojureCLR = CLR or even what CLR stands for) and I couldn't figure out if the bug had already been reported (every search seemed to turn up lots of results that were not relevant, didn't include all my search terms).  And I didn't see any &quot;Read this before submitting a bug report!!&quot; page like I'd expect for a project of this size.  So my apologies if I got this wrong.&lt;/p&gt;
&lt;p&gt;Expected behavior:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user&amp;gt; (use 'clojure.pprint)&lt;br&gt;
user&amp;gt; (with-pprint-dispatch code-dispatch&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;     (write '(ns bleh
               (:refer-clojure :only [])
               (:require [blah :refer :all]))
            :pretty true))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(ns bleh&lt;br&gt;
  (:refer-clojure :only [])&lt;br&gt;
  (:require [blah :refer :all]))&lt;br&gt;
nil&lt;br&gt;
user&amp;gt; &lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Actual behavior:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user&amp;gt; (use 'clojure.pprint)&lt;br&gt;
user&amp;gt; (with-pprint-dispatch code-dispatch&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;     (write '(ns bleh
               (:refer-clojure :only [])
               (:require [blah :refer :all]))
            :pretty true))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Exception Not enough arguments for format definition  clojure.pprint/next-arg (cl_format.clj:93)&lt;br&gt;
(ns &lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2820/exception-enough-arguments-format-definition-inside-pprint</guid>
<pubDate>Mon, 22 Jan 2018 17:17:19 +0000</pubDate>
</item>
<item>
<title>NPE when print-duping Void/TYPE</title>
<link>https://ask.clojure.org/index.php/3336/npe-when-print-duping-void-type</link>
<description>&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user=&amp;gt; (binding [*print-dup* true] (print Void/TYPE))&lt;/p&gt;
&lt;p&gt;NullPointerException   java.io.PrintWriter.write (PrintWriter.java:473)&lt;/p&gt;
&lt;h2&gt;=(identity user=&amp;gt;&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Patch:&lt;/strong&gt; 0001-CLJ-2238-handle-Void-TYPE-in-print-dup.patch&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3336/npe-when-print-duping-void-type</guid>
<pubDate>Tue, 19 Sep 2017 01:44:16 +0000</pubDate>
</item>
<item>
<title>#clojure/var tag for transmitting var identity</title>
<link>https://ask.clojure.org/index.php/3810/clojure-var-tag-for-transmitting-var-identity</link>
<description>&lt;p&gt;Currently one can't send vars around in edn. #' is clojure reader specific. Objective is to transmit var identity and bind to same-named var on reading side (a la var serialization support). &lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Proposed:&lt;/strong&gt; This is not generic enough to add to edn, so use #clojure/var for tag. Printing may print #clojure/var instead of #' (perhaps via a flag) - needs more assessment. #clojure/var tag reader should be installed in data readers.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Patch:&lt;/strong&gt; vartag2.patch&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3810/clojure-var-tag-for-transmitting-var-identity</guid>
<pubDate>Mon, 22 May 2017 15:00:58 +0000</pubDate>
</item>
<item>
<title>Suppress printing namespace map literal syntax when only one namespaced key</title>
<link>https://ask.clojure.org/index.php/1959/suppress-printing-namespace-literal-syntax-when-namespaced</link>
<description>Really an aesthetic choice, but right now maps with only a single namespaced key are printed in namespace map literal syntax:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; {:my.ns/b 1}&lt;br /&gt;
#:my.ns{:b 1}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
And that seems unnecessarily complicated (and longer).&lt;br /&gt;
&lt;br /&gt;
*Proposal:* Only print namespace map literal syntax when &amp;gt;1 key is using the same namespace.&lt;br /&gt;
&lt;br /&gt;
*Patch:* clj-1986.patch</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1959/suppress-printing-namespace-literal-syntax-when-namespaced</guid>
<pubDate>Thu, 21 Jul 2016 20:31:13 +0000</pubDate>
</item>
<item>
<title>cl-format is too slow for production use</title>
<link>https://ask.clojure.org/index.php/3834/cl-format-is-too-slow-for-production-use</link>
<description>Run this example code:&lt;br /&gt;
&lt;br /&gt;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
(in-ns 'clojure.pprint)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(println &amp;quot;Basic output using raw str.&amp;quot;)&lt;br /&gt;
(time&lt;br /&gt;
&amp;nbsp;(doseq [i (range 1000)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(apply str (interpose &amp;quot;,&amp;quot; [1 2 3]))))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(println &amp;quot;Test 1 - raw cl-format&amp;quot;)&lt;br /&gt;
(time&lt;br /&gt;
&amp;nbsp;(doseq [i (range 1000)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(clojure.pprint/cl-format nil &amp;quot;~{~D~^,~}&amp;quot; [1 2 3])))&lt;br /&gt;
;; ==&amp;gt; &amp;quot;Elapsed time: 231.345 msecs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(println &amp;quot;Test 2 - call on the compiled format&amp;quot;)&lt;br /&gt;
(def myx&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(compile-format &amp;nbsp;&amp;quot;~{~D~^,~}&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
(time&lt;br /&gt;
&amp;nbsp;(doseq [i (range 1000)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(clojure.pprint/cl-format nil myx [1 2 3])))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(println &amp;quot;Test 3 - using a formatter&amp;quot;)&lt;br /&gt;
(def myy&lt;br /&gt;
&amp;nbsp;&amp;nbsp;(formatter &amp;nbsp;&amp;quot;~{~D~^,~}&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
(time&lt;br /&gt;
&amp;nbsp;(doseq [i (range 1000)]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(myy nil myx [1 2 3])))&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(time&lt;br /&gt;
&amp;nbsp;(dotimes (i 100000)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(format nil &amp;nbsp;&amp;quot;~{~D~^,~}&amp;quot; '(1 2 3))))&lt;br /&gt;
&lt;br /&gt;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;&lt;br /&gt;
&lt;br /&gt;
It will print something like this:&lt;br /&gt;
&lt;br /&gt;
Basic output using raw str.&lt;br /&gt;
&amp;quot;Elapsed time: 2.402 msecs&amp;quot;&lt;br /&gt;
Test 1 - raw cl-format&lt;br /&gt;
&amp;quot;Elapsed time: 194.405 msecs&amp;quot;&lt;br /&gt;
Test 2 - call on the compiled format&lt;br /&gt;
&amp;quot;Elapsed time: 87.271 msecs&amp;quot;&lt;br /&gt;
Test 3 - using a formatter&lt;br /&gt;
&amp;quot;Elapsed time: 199.318 msecs&amp;quot;&lt;br /&gt;
&lt;br /&gt;
So raw `str' is ~ 100X faster.&lt;br /&gt;
&lt;br /&gt;
For reference, on the same hardware, using&lt;br /&gt;
SBCL Common Lisp, this test runs in &amp;lt; 1 ms.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
There are (at least) 2 problems here:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;1. cl-format function begins with a line like:&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;let [compiled-format (if (string? format-in) (compile-format format-in) format-in)&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;But there is no api to pass in a compiled-format into it; (as compile-format&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;is a private function, so can't be used at large) so this is kind of useless.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;2. Even using a precompiled formatter is way too slow.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Suggested fix: none, except perhaps warning unwary users that this&lt;br /&gt;
function is simply not suitable for tight loops, and should only be&lt;br /&gt;
used to pretty print user input strings, etc.&lt;br /&gt;
&lt;br /&gt;
Thank you</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3834/cl-format-is-too-slow-for-production-use</guid>
<pubDate>Mon, 06 Jun 2016 05:41:02 +0000</pubDate>
</item>
<item>
<title>enhance pprint to print type for defrecord (as in pr)</title>
<link>https://ask.clojure.org/index.php/4265/enhance-pprint-to-print-type-for-defrecord-as-in-pr</link>
<description>pprint currently doesn't print the names of defrecord types, instead printing just the underlying map. This is in contrast to pr-str/println. This ticket proposes that the behaviour of pprint is changed to match pr-str and println's.&lt;br /&gt;
&lt;br /&gt;
More discussion at &lt;a href=&quot;https://groups.google.com/forum/#!topic/clojure-dev/lRDG6a5eE-s&quot; rel=&quot;nofollow&quot; target=&quot;_blank&quot;&gt;https://groups.google.com/forum/#!topic/clojure-dev/lRDG6a5eE-s&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (defrecord myrec [a b])&lt;br /&gt;
user.myrec&lt;br /&gt;
user=&amp;gt; (-&amp;gt;myrec 1 2)&lt;br /&gt;
#user.myrec{:a 1, :b 2}&lt;br /&gt;
user=&amp;gt; (pr-str (-&amp;gt;myrec 1 2))&lt;br /&gt;
&amp;quot;#user.myrec{:a 1, :b 2}&amp;quot;&lt;br /&gt;
user=&amp;gt; (println (-&amp;gt;myrec 1 2))&lt;br /&gt;
#user.myrec{:a 1, :b 2}&lt;br /&gt;
nil&lt;br /&gt;
user=&amp;gt; (pprint (-&amp;gt;myrec 1 2))&lt;br /&gt;
{:a 1, :b 2}&lt;br /&gt;
nil&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
*Approach:* Add new IRecord case to pprint's simple-dispatch mode. Extract guts of pprint-map to pprint-map-kvs and call it from both existing pprint-map and new pprint-record. Set multimethod preference for IRecord version. Added test.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (pprint (-&amp;gt;myrec 1 2))&lt;br /&gt;
#user.myrec{:a 1, :b 2}&lt;br /&gt;
&lt;br /&gt;
*Patch:* CLJ-1890-pprint-records-2.patch&lt;br /&gt;
&lt;br /&gt;
*Prescreened by:* Alex Miller&lt;br /&gt;
&lt;br /&gt;
*Also see:* CLJS-1753</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4265/enhance-pprint-to-print-type-for-defrecord-as-in-pr</guid>
<pubDate>Fri, 05 Feb 2016 19:36:21 +0000</pubDate>
</item>
<item>
<title>Add the ability to rename columns in clojure.pprint/print-table</title>
<link>https://ask.clojure.org/index.php/3363/add-the-ability-to-rename-columns-clojure-pprint-print-table</link>
<description>I suggest adding the ability to rename columns in {{clojure.pprint/print-table}}, with the following interface:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(print-table [[:b &amp;quot;column b&amp;quot;] [:a &amp;quot;a&amp;quot;]]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;[{:a 1 :b {:a 'is-a} :c [&amp;quot;hi&amp;quot; &amp;quot;there&amp;quot;]}&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{:b 5 :a 7 :c &amp;quot;dog&amp;quot; :d -700}])&lt;br /&gt;
&lt;br /&gt;
| &amp;nbsp;column b | &amp;nbsp;a |&lt;br /&gt;
|-----------+----|&lt;br /&gt;
| {:a is-a} | &amp;nbsp;1 |&lt;br /&gt;
| &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5 | &amp;nbsp;7 |&lt;br /&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3363/add-the-ability-to-rename-columns-clojure-pprint-print-table</guid>
<pubDate>Thu, 24 Dec 2015 06:26:52 +0000</pubDate>
</item>
<item>
<title>cl-format does not respect aesthetic ~A with a keyword</title>
<link>https://ask.clojure.org/index.php/1918/cl-format-does-not-respect-aesthetic-a-with-a-keyword</link>
<description>&lt;p&gt;In Common Lisp, (format nil &quot;~a&quot; :A) returns &quot;A&quot;. However, in Clojure, it returns with the colon:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;(clojure.pprint/cl-format false &quot;~a&quot; :A)
=&amp;gt; &quot;:A&quot;&lt;/code&gt;&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1918/cl-format-does-not-respect-aesthetic-a-with-a-keyword</guid>
<pubDate>Sat, 26 Sep 2015 13:54:45 +0000</pubDate>
</item>
<item>
<title>Replace refs in pprint</title>
<link>https://ask.clojure.org/index.php/1518/replace-refs-in-pprint</link>
<description>&lt;p&gt;I noticed that pprint uses refs and dosync transactions in a number of places, which seems unlikely to be necessary. It seems like these could be replaced by atoms, or even volatiles, given that printing typically happens in a single thread. Presumably this would improve performance of pprint significantly.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1518/replace-refs-in-pprint</guid>
<pubDate>Thu, 13 Aug 2015 14:09:36 +0000</pubDate>
</item>
<item>
<title>pr-str captures stdout from printing side-effects of lazily evaluated expressions.</title>
<link>https://ask.clojure.org/index.php/2791/captures-stdout-printing-effects-lazily-evaluated-expressions</link>
<description>&lt;p&gt;Because clojure.core/pr-str uses with-out-str to capture the output of pr (and pr cannot be parsed a writable thing - just uses &lt;strong&gt;out&lt;/strong&gt;). &lt;/p&gt;
&lt;p&gt;If you pr-str the result of something lazy you can get side-effects written to stdout with println interspersed with the output. For example in my case I was extracting benchmarks from the library criterium and trying to print the data structure to the file. The solution would be to provide an overload of pr/pr-str that takes a writer. I note that pr-on provides some of the functionality but it is private.&lt;/p&gt;
&lt;p&gt;This is an ugly bug when you're trying to persist program output in EDN, because the randomly interspersed stdout messages make it invalid for read-string. We shouldn't need our functions to be pure for pr-str to work as expected.&lt;/p&gt;
&lt;p&gt;I've omitted a patch because although I think a fix is straight-forward I'm not sure quite where it should go (e.g. make pr-on public, change pr, change pr-str)&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2791/captures-stdout-printing-effects-lazily-evaluated-expressions</guid>
<pubDate>Tue, 23 Sep 2014 15:45:01 +0000</pubDate>
</item>
<item>
<title>Option to print type info</title>
<link>https://ask.clojure.org/index.php/759/option-to-print-type-info</link>
<description>I've had an issue with defrecord-types being converted into ordinary maps somewhere, which was relatively hard to track down inside a deep structure since they are pprinted as the same thing by default.&lt;br /&gt;
The following code patches into the pprint dispatch and prints the type around values; it turned out to be quite useful, but feels hackish.&lt;br /&gt;
Maybe something like that would be useful to integrate into clojure.pprint directly (there are a number of cosmetic options already), i.e. into clojure.pprint/write-out.&lt;br /&gt;
&lt;br /&gt;
Only printing {{(type)}} may not be enough in some cases; so an option to print all metadata would be nice.&lt;br /&gt;
Maybe something like {{:metadata nil}} as default, {{:metadata :type}} to print types (but also for non-IMetas, using {{(type)}} and {{:metadata true}} to print metadata for IMetas using {{(meta)}}.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
(defn pprint-with-type&lt;br /&gt;
&amp;nbsp;&amp;nbsp;([object] (pprint object *out*))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;([object writer]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;; keep original dispatch.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;; calling it directly will print only that object,&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;; but return to our dispatch for subobjects.&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;(let [dispatch clojure.pprint/*print-pprint-dispatch*]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(binding [clojure.pprint/*print-pprint-dispatch*&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(fn [obj]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(if (instance? clojure.lang.IMeta obj)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(do (print &amp;quot;^{:type &amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(dispatch (type obj))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(print &amp;quot;} &amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(clojure.pprint/pprint-newline :fill)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(dispatch obj))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(do (print &amp;quot;(^:type &amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(dispatch (type obj))&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(print &amp;quot; &amp;quot;)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(clojure.pprint/pprint-newline :fill)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(dispatch obj)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(print &amp;quot;)&amp;quot;))))]&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;(clojure.pprint/pprint object writer)))))&lt;br /&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/759/option-to-print-type-info</guid>
<pubDate>Mon, 21 Jul 2014 17:07:49 +0000</pubDate>
</item>
<item>
<title>cl-format throws ClassCastException: Writer cannot be cast to Future/IDeref</title>
<link>https://ask.clojure.org/index.php/1560/format-throws-classcastexception-writer-cannot-future-ideref</link>
<description>&lt;p&gt;Using &lt;code&gt;\~I&lt;/code&gt; and &lt;code&gt;\~_&lt;/code&gt; etc fails in many situations, the most trivial one being:&lt;/p&gt;
&lt;p&gt;Clojure 1.6.0 and 1.5.1:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;user=&amp;gt; (clojure.pprint/cl-format true &quot;~I&quot;)
ClassCastException java.io.PrintWriter cannot be cast to java.util.concurrent.Future  clojure.core/deref-future (core.clj:2180)
user=&amp;gt; (clojure.pprint/cl-format nil &quot;~I&quot;)
ClassCastException java.io.StringWriter cannot be cast to java.util.concurrent.Future  clojure.core/deref-future (core.clj:2180)
user=&amp;gt; (clojure.pprint/cl-format nil &quot;~_&quot;)
ClassCastException java.io.StringWriter cannot be cast to java.util.concurrent.Future  clojure.core/deref-future (core.clj:2180)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;Clojure 1.4.0&lt;/p&gt;
&lt;p&gt;&lt;code&gt;user=&amp;gt; (clojure.pprint/cl-format true &quot;~I&quot;)
ClassCastException java.io.OutputStreamWriter cannot be cast to clojure.lang.IDeref  clojure.core/deref (core.clj:2080)
user=&amp;gt; (clojure.pprint/cl-format nil &quot;~I&quot;)
ClassCastException java.io.StringWriter cannot be cast to clojure.lang.IDeref  clojure.core/deref (core.clj:2080)
user=&amp;gt; (clojure.pprint/cl-format nil &quot;~_&quot;)
ClassCastException java.io.StringWriter cannot be cast to clojure.lang.IDeref  clojure.core/deref (core.clj:2080)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;These work in other implementations, i.e. clisp, creating empty output in these trivial cases:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;&amp;gt; (format t &quot;~I&quot;)
NIL
&amp;gt; (format nil &quot;~I&quot;)
&quot;&quot;
&amp;gt; (format nil &quot;~_&quot;)
&quot;&quot;&lt;/code&gt;&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1560/format-throws-classcastexception-writer-cannot-future-ideref</guid>
<pubDate>Mon, 07 Jul 2014 16:55:27 +0000</pubDate>
</item>
<item>
<title>pprint prints some metadata when *print-meta* bound to true, but not all</title>
<link>https://ask.clojure.org/index.php/3315/pprint-prints-some-metadata-when-print-meta-bound-true-but-not</link>
<description>Short example illustrating the behavior:&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; *clojure-version*&lt;br /&gt;
{:major 1, :minor 6, :incremental 0, :qualifier nil}&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (def f1 '(defn foo [^Integer x] ^{:bar 8} (inc x)))&lt;br /&gt;
#'user/f1&lt;br /&gt;
&lt;br /&gt;
;; pr shows all metadata, as expected&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (binding [*print-meta* true] (pr f1))&lt;br /&gt;
^{:line 2, :column 10} (defn foo [^Integer x] ^{:bar 8, :line 2, :column 33} (inc x))nil&lt;br /&gt;
&lt;br /&gt;
;; pprint shows some metadata, but not all&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (binding [*print-meta* true] (clojure.pprint/pprint f1))&lt;br /&gt;
(defn foo [^Integer x] (inc x))&lt;br /&gt;
nil&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
I have not dug into the details yet, but it appears that this may be because pprint uses pr to show symbols, but not to show collections. &amp;nbsp;Thus pprint shows metadata on symbols, but not collections.&lt;br /&gt;
&lt;br /&gt;
It would be nice if pprint could instead show all metadata, as pr does, when *print-meta* is bound to true.</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/3315/pprint-prints-some-metadata-when-print-meta-bound-true-but-not</guid>
<pubDate>Fri, 13 Jun 2014 17:02:46 +0000</pubDate>
</item>
<item>
<title>print-dup's handling of metadata typehint is unreadable in some circumstances</title>
<link>https://ask.clojure.org/index.php/2771/print-handling-metadata-typehint-unreadable-circumstances</link>
<description>&lt;p&gt;With &lt;strong&gt;print-dup&lt;/strong&gt; true, if an object being printed has a metadata map with only a :tag key, the printer renders it as &quot;^value&quot;.  This can cause an IllegalArgumentException if you try to read the printed string back in, in some circumstances.  E.g.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;  user=&amp;gt; (read-string (let [ge (with-meta (gensym) {:tag Object})] (binding [*print-dup* true] (pr-str ge))))
  IllegalArgumentException Metadata must be Symbol,Keyword,String or Map  clojure.lang.LispReader$MetaReader.invoke (LispReader.java:732)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;This is causing problems with sleight/riddley's (link: 1) handling of the (case) macro, which drops a type-hint on a gensym it incorporates in the form it returns.  When sleight tries to reserialize a macroexpanded (case) form from riddley, it fails as demonstrated above.  E.g.&lt;/p&gt;
&lt;p&gt;&lt;code&gt;  user=&amp;gt; (read-string (binding [*print-dup* true] (pr-str (macroexpand '(case 1 1 1)))))
  user=&amp;gt; IllegalArgumentException Metadata must be Symbol,Keyword,String or Map  clojure.lang.LispReader$MetaReader.invoke (LispReader.java:732)&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The attached patch corrects this by making core_print.clj's print-meta always print out the full metadata map if &lt;strong&gt;print-dup&lt;/strong&gt; is true.  The patch also contains a test for this case.&lt;/p&gt;
&lt;p&gt;(link: 1) &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/ztellman/sleight&quot;&gt;https://github.com/ztellman/sleight&lt;/a&gt; &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/ztellman/riddley&quot;&gt;https://github.com/ztellman/riddley&lt;/a&gt;&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2771/print-handling-metadata-typehint-unreadable-circumstances</guid>
<pubDate>Thu, 03 Oct 2013 04:22:22 +0000</pubDate>
</item>
<item>
<title>print-table displays tables incorrectly when one of the cells is a string that has newlines</title>
<link>https://ask.clojure.org/index.php/1183/print-table-displays-tables-incorrectly-cells-string-newlines</link>
<description>&lt;p&gt;When using print-table to print an ASCII table to stdout, the table display breaks if any of the values is a string with any new lines in it. For example:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user=&amp;gt; (print-table [{:a &quot;test&quot; :b &quot;test\ntest2&quot;}])&lt;/p&gt;
&lt;p&gt;|   :a |         :b |&lt;br&gt;
|------+------------|&lt;br&gt;
| test | test&lt;br&gt;
test2 |&lt;br&gt;
nil&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;I would expect the output to look something like this:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user=&amp;gt; (print-table [{:a &quot;test&quot; :b &quot;test\ntest2&quot;}])&lt;/p&gt;
&lt;p&gt;|   :a |         :b |&lt;br&gt;
|------+------------|&lt;br&gt;
| test | test       +&lt;br&gt;
|      | test2      |&lt;br&gt;
nil&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;The + symbol on the right border means that the row continues over multiple lines. This is similar to how the PostgreSQL psql tool displays table with multi-line rows:&lt;/p&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
user=# select 'test' col1, E'test\ntest2\ntest3' col2;&lt;br&gt;
 col1 | col2&lt;br&gt;
------+-------&lt;br&gt;
 test | test +&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;  | test2+
  | test3
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;(1 row)&lt;/p&gt;
&lt;p&gt;Time: 0.776 ms&lt;br&gt;
&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1183/print-table-displays-tables-incorrectly-cells-string-newlines</guid>
<pubDate>Tue, 09 Jul 2013 20:02:30 +0000</pubDate>
</item>
<item>
<title>clojure.pprint/code-dispatch breaks on certain types of anonymous functions</title>
<link>https://ask.clojure.org/index.php/752/clojure-pprint-dispatch-breaks-certain-anonymous-functions</link>
<description>&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;br&gt;
(with-out-str &lt;br&gt;
  (with-pprint-dispatch code-dispatch &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;                    (pp/pprint (read-string &quot;(fn* [x] x)&quot;))))
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;`&lt;/code&gt;&lt;/p&gt;
&lt;p&gt;breaks because the format string here: &lt;a rel=&quot;nofollow&quot; href=&quot;https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/dispatch.clj#L378&quot;&gt;https://github.com/clojure/clojure/blob/master/src/clj/clojure/pprint/dispatch.clj#L378&lt;/a&gt; expects a sequence. In the case of (fn*  (link: x) x) it is passed a symbol.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/752/clojure-pprint-dispatch-breaks-certain-anonymous-functions</guid>
<pubDate>Sun, 10 Mar 2013 22:40:12 +0000</pubDate>
</item>
<item>
<title>Make print-sequential interruptible</title>
<link>https://ask.clojure.org/index.php/1940/make-print-sequential-interruptible</link>
<description>&lt;p&gt;This allows print-sequential to be interrupted by Thread.interrupt(), rather than requiring clients to resort to Thread.stop(). This is especially helpful when printing very large sequences.&lt;/p&gt;
&lt;p&gt;See also clojure-dev discussion at &lt;a rel=&quot;nofollow&quot; href=&quot;https://groups.google.com/d/topic/clojure-dev/vs0RNUQXiYE/discussion&quot;&gt;https://groups.google.com/d/topic/clojure-dev/vs0RNUQXiYE/discussion&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Patch:&lt;/strong&gt; clj-1073-add-print-interruptibly-patch-v2.txt&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt; &lt;/p&gt;
&lt;p&gt;Add a new var &lt;strong&gt;print-interruptibly&lt;/strong&gt;, similar to &lt;strong&gt;print-length&lt;/strong&gt;, &lt;strong&gt;print-dup&lt;/strong&gt;, etc.  Its default is false.  When true, (Thread/interrupted) is checked for after printing each element of a sequence.  If true, the writer is flushed and an InterruptedIOException is thrown.&lt;/p&gt;
&lt;p&gt;An alternative patch proposed earlier did not include &lt;strong&gt;print-interruptibly&lt;/strong&gt;, but simply always checked (Thread/interrupted) after printing each element of a sequence.  Benchmark tests showed that this could slow down printing of long sequences by about 10%.  The approach in the proposed patch only incurs this slowdown if &lt;strong&gt;print-interruptibly&lt;/strong&gt; is true.  When false, there is no significant slowdown measured in benchmarks.&lt;/p&gt;
</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1940/make-print-sequential-interruptible</guid>
<pubDate>Fri, 21 Sep 2012 22:10:46 +0000</pubDate>
</item>
<item>
<title>pr-str and read-string don't handle @ symbols inside keywords properly</title>
<link>https://ask.clojure.org/index.php/2400/str-read-string-dont-handle-symbols-inside-keywords-properly</link>
<description>&lt;br /&gt;
user=&amp;gt; (read-string (pr-str {(keyword &amp;quot;key@other&amp;quot;) :stuff}))&lt;br /&gt;
RuntimeException Map literal must contain an even number of forms &amp;nbsp;clojure.lang.Util.runtimeException (Util.java:170)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
pr-str emits &amp;quot;{:key@other :stuff}&amp;quot;, which read-string fails to interpret correctly. Either pr-str needs to escape the @ symbol, or read-string needs to handle the symbol inside a keyword.&lt;br /&gt;
&lt;br /&gt;
Background: I'm passing a map with email addresses as keys through Storm bolts, which require a thrift-serializable form. Using the pr-str/read-string combo fails on these keys, so I've fallen back to JSON serialization.</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/2400/str-read-string-dont-handle-symbols-inside-keywords-properly</guid>
<pubDate>Thu, 26 Jul 2012 17:25:39 +0000</pubDate>
</item>
<item>
<title>clojure.pprint uses the old-style metadata.</title>
<link>https://ask.clojure.org/index.php/4641/clojure-pprint-uses-the-old-style-metadata</link>
<description>I was looking through the implementation of clojure.pprint.* and found that it still uses the old-style metadata to mark vars as private - ^{:private true} instead of ^:private.&lt;br /&gt;
&lt;br /&gt;
I have migrated the metadata to the new style in the attached trivial patch, which can be used in case this is deemed to be an issue.&lt;br /&gt;
&lt;br /&gt;
FWIW, there are some other namespaces which use the old-style metadata as well; I am willing to fix those as well.</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/4641/clojure-pprint-uses-the-old-style-metadata</guid>
<pubDate>Mon, 26 Sep 2011 08:35:36 +0000</pubDate>
</item>
<item>
<title>hash-maps print-dup as literal, thus can be read as array-maps</title>
<link>https://ask.clojure.org/index.php/1182/hash-maps-print-dup-as-literal-thus-can-be-read-as-array-maps</link>
<description>Per Rich in CLJ-799: &amp;quot;The point of print-dup is type preservation&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
user=&amp;gt; (hash-map :k :v)&lt;br /&gt;
{:k :v}&lt;br /&gt;
user=&amp;gt; (type *1)&lt;br /&gt;
clojure.lang.PersistentHashMap&lt;br /&gt;
user=&amp;gt; (binding [*print-dup* true] (print-str *2))&lt;br /&gt;
&amp;quot;{:k :v}&amp;quot;&lt;br /&gt;
user=&amp;gt; (read-string *1)&lt;br /&gt;
{:k :v}&lt;br /&gt;
user=&amp;gt; (type *1)&lt;br /&gt;
clojure.lang.PersistentArrayMap&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The cause is due to {{RT.map}} conditionally creating an array-map if the size is within the {{PersistentArrayMap.HASHTABLE_THRESHOLD}}.</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/1182/hash-maps-print-dup-as-literal-thus-can-be-read-as-array-maps</guid>
<pubDate>Tue, 07 Jun 2011 21:14:49 +0000</pubDate>
</item>
<item>
<title>(pprint-newline :fill) is not handled correctly</title>
<link>https://ask.clojure.org/index.php/780/pprint-newline-fill-is-not-handled-correctly</link>
<description>Filled pretty printing (where we try to fit as many elements on a line as possible) is being too aggressive as we can see when we try to print the following array:&lt;br /&gt;
&lt;br /&gt;
user&amp;gt; (binding [*print-right-margin* 20] (pprint (int-array (range 10))))&lt;br /&gt;
&lt;br /&gt;
Produces:&lt;br /&gt;
&lt;br /&gt;
[0,&lt;br /&gt;
&amp;nbsp;1,&lt;br /&gt;
&amp;nbsp;2,&lt;br /&gt;
&amp;nbsp;3,&lt;br /&gt;
&amp;nbsp;4, 5, 6, 7, 8, 9]&lt;br /&gt;
&lt;br /&gt;
Rather than &lt;br /&gt;
&lt;br /&gt;
[0, 1, 2, 3, 4,&lt;br /&gt;
&amp;nbsp;5, 6, 7, 8, 9]&lt;br /&gt;
&lt;br /&gt;
or something like that. (I haven't worked through the exact correct representation for this case).&lt;br /&gt;
&lt;br /&gt;
We currently only use :fill style newlines for native java arrays.</description>
<category>Printing</category>
<guid isPermaLink="true">https://ask.clojure.org/index.php/780/pprint-newline-fill-is-not-handled-correctly</guid>
<pubDate>Wed, 12 May 2010 15:45:00 +0000</pubDate>
</item>
</channel>
</rss>