I recently ran into this problem again. The solution I came up with is:
(defn filter-printable [obj] (cond (or (symbol? obj) (number? obj) (string? obj) (keyword? obj)) obj (vector? obj) (apply vector (map filter-printable obj)) (seq? obj) (map filter-printable obj) (set? obj) (into #{} (map filter-printable obj)) (map? obj) (into {} (for [[k v] obj] [(filter-printable v) (filter-printable v)])) true [:un-readable (pr-str obj)])) ## example: (filter-printable {:k 20 :f 'abc :d '(+ 1 2 3 foo) :other (async/chan 10)}) Anyone have a better / more elegant solution? On Thu, Jan 16, 2014 at 10:17 AM, t x <txrev...@gmail.com> wrote: > After looking at edn/read-string and realizing I would have to modify Java > code, I have decided that modifying the sender in clojure land isn't so bad > after all. > > > On Thu, Jan 16, 2014 at 9:41 AM, Alex Miller <a...@puredanger.com> wrote: > >> I think I would change the sender to elide whatever parts you don't want >> to send rather than mess with the receiver. >> >> >> On Thursday, January 16, 2014 2:11:02 AM UTC-6, t x wrote: >>> >>> Hi, >>> >>> Right now if I do (clojure.edn/read-string ...) on a string with a >>> unreadable part, I get an exception. Instead, I would like to just get nil. >>> For example: >>> >>> >>> ## code >>> >>> (clojure.edn/read-string >>> (pr-str >>> {:tag :message >>> :chan (async/chan 10)})) >>> >>> ## currently returns >>> >>> java.lang.RuntimeException: Unreadable form >>> at clojure.lang.Util.runtimeException (Util.java:219) >>> >>> >>> ## instead, I would like: >>> >>> {:tag :message >>> :chan :nil} >>> >>> >>> Is there a way to make this happen? >>> >>> Thanks! >>> >> -- >> -- >> You received this message because you are subscribed to the Google >> Groups "Clojure" group. >> To post to this group, send email to clojure@googlegroups.com >> Note that posts from new members are moderated - please be patient with >> your first post. >> To unsubscribe from this group, send email to >> clojure+unsubscr...@googlegroups.com >> For more options, visit this group at >> http://groups.google.com/group/clojure?hl=en >> --- >> You received this message because you are subscribed to the Google Groups >> "Clojure" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to clojure+unsubscr...@googlegroups.com. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- -- You received this message because you are subscribed to the Google Groups "Clojure" group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups "Clojure" group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.