[racket] read of numbers with decimal point default to exact?

From: Robby Findler (robby at eecs.northwestern.edu)
Date: Fri Jul 23 08:52:49 EDT 2010

On Fri, Jul 23, 2010 at 7:40 AM, Neil Van Dyke <neil at neilvandyke.org> wrote:
> Robby Findler wrote at 07/23/2010 08:09 AM:
>>
>> The read-decimal-as-inexact parameter allows you to change read's
>> behavior in this way. Is that what you're looking for?
>
> Yes (with the addition of a corresponding write parameter), but...

That's available via pretty-print, fwiw.

> * I was idly toying with the idea of that being the default.  It's a little
> funny that the Scheme number system lets a naive programmer use arbitrarily
> huge numbers, yet a naive programmer evaluating "(/ 3.3 1.1)" gets an
> 'incorrect' answer.  I won't belabor this point further.

FWIW, the teaching languages do this already if you want to play around there.

> * To support programmers who want to use exact numbers by default, such as
> some financial programmers, without making that the default for Racket,
> let's say we define a new Racket variant for these programmers ("#lang
> numbers-racket", heh).  In this case, I'm wondering whether there is a
> problem with any Racket *libraries* confusing these programmers when the
> numbers they get out of the libraries can quietly become inexact.  Perhaps
> the solution here is simply that authors of numerical libraries should
> provide multiple two versions of certain of operations: a version that
> preserves exactness, and a version that is fast?

In the teaching languages we made inexacts print with a leading "#i"
to avoid some of this problem.

Robby


Posted on the users mailing list.