Welcome! Please see the About page for a little more info on how this works.

+3 votes
in Printing by
edited by

Repro:

;; print-method

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

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

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

;; clojure.pprint

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

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

user=> (binding [*print-level* 1]
         (clojure.pprint/pprint
           [(clojure.lang.MapEntry. :a 1)
            (clojure.lang.MapEntry. :b 1)]))
[# #]
nil

The docstring for *print-level* says:

If an object is a collection and is at a level greater than or equal to the value bound to print-level, the printer prints '#' to represent it.

A map entry is a collection and in {:a 1, :b 2} is at a level equal to *print-level*, so I would expect prn to have the same output as clojure.pprint.

Please log in or register to answer this question.

...