Re: clojure.edn/read-string exceptions => nil

2014-01-26 Thread Cedric Greevey
Shouldn't that be: (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 {

Re: clojure.edn/read-string exceptions => nil

2014-01-26 Thread t x
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

Re: clojure.edn/read-string exceptions => nil

2014-01-16 Thread t x
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 wrote: > I think I would change the sender to elide whatever parts you don't want > to s

Re: clojure.edn/read-string exceptions => nil

2014-01-16 Thread Alex Miller
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.

Re: clojure.edn/read-string exceptions => nil

2014-01-16 Thread Luc Prefontaine
Oups, skipped the last part of your emal. With edn I see no way to do this. Luc > Either you misunderstood my question or I misunderstood your answer. > > I don't want the entire expression to return nil. I only want the > _unparsable_ part to return nil. > > Thus, the above answer should be

Re: clojure.edn/read-string exceptions => nil

2014-01-16 Thread Bronsa
What you want is currently not possible. If you need this functionality, I'll take a patch for tools.reader that adds a :nil-on-unreadable option to clojure.tools.reader.edn/read. Il giorno 16/gen/2014 11.05, "t x" ha scritto: > Either you misunderstood my question or I misunderstood your answer

Re: clojure.edn/read-string exceptions => nil

2014-01-16 Thread t x
Either you misunderstood my question or I misunderstood your answer. I don't want the entire expression to return nil. I only want the _unparsable_ part to return nil. Thus, the above answer should be {:tag :message :chan ni} rather than nil On Thu, Jan 16, 2014 at 1:47 AM, Luc Prefontaine <

Re: clojure.edn/read-string exceptions => nil

2014-01-16 Thread Luc Prefontaine
Wrap the read in a try catch just return nil in the catch clause for this specific exception and wrap it in a function for ease of use. You might want to throw up any other exceptions and only catch this one Luc P. > I should add: this problem arises due to cljs / clojure talking over the >

Re: clojure.edn/read-string exceptions => nil

2014-01-16 Thread t x
I should add: this problem arises due to cljs / clojure talking over the network, so: (*) not using serialization is NOT an option (*) however, I don't have to use edn/read-string + pr-str (*) it's perfectly fine to use different encoding/decoding methods On Thu, Jan 16, 2014 at 12:11 AM, t x