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

0 votes
in Protocols by

I've created a circular data structure using atoms and an attempts to print this data structure results in a stackoverflow since string format of an atom contains it's value:

=> #object[clojure.lang.Atom 0x6b932895 {:status :ready, :val "recursive"}]

How do I change how atoms are displayed in repl? Is it possible to somehow keep this change localized?

1 Answer

+1 vote
by

You can supply a new print-method / print-dup for clojure.lang.Atom, something like:

(defmethod print-method clojure.lang.Atom [obj ^java.io.Writer w] 
  (.write w "#atom"))
...