To my understanding, Clojure's pr
function prints objects so that when read back will be =
to the original object. My main source for this come s from this talk https://youtu.be/pbodL96HM28?t=216 from Clojure core developer Stuart Sierra ( I cannot find any docs to say what guarantees pr offers).
If this is correct, then pr
is not working for java.sql.Timestamp and java.util.Calendar. For example, this returns false.
(let [d (java.sql.Timestamp. 1)]
(= d
(read-string
(pr-str d))))
Further, Clojure's documentation says , print-dup, when true, means that objects will be printed in a way that preserves their type when read in later
This is not the case for java.sql.Timestamp and java.util.Calendar
`
(binding [*print-dup* true]
(prn (java.sql.Timestamp. 1)))
=> #inst "1970-01-01T00:00:00.001000000-00:00"
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 https://clojure.atlassian.net/browse/CLJ-2224 .
I understand the above behaviour can be changed by users, but I am asking about the default implementations.