On Thu, Oct 20, 2011 at 23:16, Stuart Halloway
<stuart.hallo...@gmail.com> wrote:
>>>> It appears that the answer to the original question is "no, there is no 
>>>> way to configure the reader to default numbers with a decimal point to be 
>>>> BigDecimal instead of Double".
>>>>
>>>> Scott Hickey
>>>
>>> Reading a double implies that somebody upstream of you was using doubles, 
>>> which violates the guarantees you want from BigDecimals.
>>>
>>> Why is the upstream provider using doubles?
>>
>> I don't follow. The OP has text, which Clojure is reading as doubles.
>> This only implies that upstream (which need not have been written in
>> Clojure) is producing numbers matching #"[-]?[1-9][0-9]*[.][0-9]*|0",
>> because LispReader interprets that as Double. Whatever internal
>> representation this text was produced form may or may not have been
>> (binary) floating point initially.
>>
>> It doesn't seem reasonable to assume that the OP's "'business'
>> applications I've built over the last 25 years" could have known that
>> Clojure would come along later and expect to find "M" on the end of
>> every decimal number.
>>
>> // Ben
>
> Hmm, highly apropos discussion since Rich's talk on simplicity posted today.
>
> The reader does one thing: read Clojure data. Sometimes you need something 
> else: read data written in another format. You might accomplish that by (1) 
> making the reader able to do two things, adding a flag to deal with a 
> specific format, or (2) by using a different reader for that job.
>
> (2) is hands-down the right answer.

No argument there. The Clojure reader's job is to read Clojure. If
your have some data that happens to be syntactically compatible, fine,
but if not the Clojure reader  isn't the right tool.

One obvious approach would be a to use a regular expression to
identify the numbers in the text to be parsed and #(BigDecimal.
^String %) to do the actual conversion.

// Ben

-- 
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

Reply via email to