On Thu, Oct 15, 2009 at 2:18 PM, Brian Hurt <[email protected]> wrote:
> So, I've hit a problem and I'm hoping for some help on how to solve it.  The
> problem is that prn and read are not perfect duals- that is, not everything
> that prn produces can be read in by read.  The specific case I'm hitting is
> with double precision infinities and NaNs. pr just calls .toString on
> doubles, which for infinities and nans returns the string "Infinity" or
> "NaN":
>
>
>> user=> (with-out-str (pr Double/POSITIVE_INFINITY))
>> "Infinity"
>> user=> (with-out-str (pr Double/NEGATIVE_INFINITY))
>> "-Infinity"
>> user=> (with-out-str (pr Double/NaN))
>> "NaN"
>> user=>
>>
>
> The problem is, when you try to read these values back in, they're
> interpreted as symbols, not as numbers:
>
>> user=> (class (with-in-str (with-out-str (pr Double/POSITIVE_INFINITY))
>> (read)))
>> clojure.lang.Symbol
>> user=>
>
>
> I'm not sure what the "right" way to solve it, but I'm inclined to advocate
> that Infinity and NaN should be reserved keywords recognized by the reader.
> Or possibly Clojure should automatically define the symbols Infinity and NaN
> to have the correct values.  I'm not sure.
>

I'll have to think about how best to handle this, but would appreciate
an issue in Assembla to track it.

Thanks,

Rich

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to