chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Chicken-hackers] [PATCH] Omit warning about exact fractions when asked


From: Peter Bex
Subject: [Chicken-hackers] [PATCH] Omit warning about exact fractions when asked for an inexact value
Date: Wed, 21 Mar 2012 22:35:54 +0100
User-agent: Mutt/1.4.2.3i

Hi!

Here's a simple patch (it only adds the (not (eq? exactness 'i)) check, but
I took the opportunity to rid us of a few of those nasty square parens :P).

It ensures the warning about exact fractions not being representable is
only emitted when the user asks for an exact value.  Currently, you
also get the warning when you type in something like "#i1/2", which is
pretty unsettling when you KNOW you've loaded the numbers egg (you still
get it then).  It also helps in core, since the warning doesn't make
much sense when the user explicitly asked for an inexact.

The warning still happens when you type in something like "1/2".  When
you type in something like "#e1/2" you still get an error from
inexact->exact complaining that it can't convert a flonum to an exact
value.  I'm not sure that's the desired behaviour, though.
If we agree it's not right and worth fixing we could fix that with
another patch (this patch doesn't change that).

I tried to move the code into ##sys#string->number like the comment
says, but that involved dropping the rat-flag (nice) in favor of doing
another pass over the string to check for "/" characters (less nice),
and the error message actually needs the "port" object to get a line
number.  I don't think there's a simple way to pass the port to
string->number without breaking r5rs compatibility and/or "numbers".

And, after thinking about it some more, I'm convinced it's not even too
bad to have the check in this place - if the user asked for an exact
and whichever flavor of string->number we are using is unable to deliver,
that's worth a warning.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth

Attachment: 0001-Only-emit-warning-about-not-being-able-to-represent-.patch
Description: Text document


reply via email to

[Prev in Thread] Current Thread [Next in Thread]