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

+1 vote
in Clojure by
retagged by

clojure.pprint/print-table calls str on the 'cols', should that really be print-str so print-method can be respected?

2 Answers

0 votes
by

Do you have a specific example where you're not seeing what you expect?

by
edited by
In the following transcript, we have a defmethod for ZonedDateTime ignored by print-table but used by print-table2  which uses (print-str col)  and not (str col)

;; hide timezone location
(defmethod print-method java.time.ZonedDateTime
  [v ^java.io.Writer w]
  (.write w "#inst \"")
  (.write w (.format v java.time.format.DateTimeFormatter/ISO_OFFSET_DATE_TIME))
  (.write w "\""))
=> #object[clojure.lang.MultiFn 0x7a030531 "clojure.lang.MultiFn@7a030531"]

(clojure.pprint/print-table [{:a (java.time.ZonedDateTime/now)}])

|                                              :a |
|-------------------------------------------------|
| 2021-04-17T20:55:56.794+12:00[Pacific/Auckland] |
=> nil

(print-table2 [{:a (java.time.ZonedDateTime/now)}])

|                                              :a |
|-------------------------------------------------|
|           #inst "2021-04-17T20:56:48.715+12:00" |
0 votes
by
...