[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-hackers] [PATCH] Improve Chicken's handling of numerical sy
From: |
John Cowan |
Subject: |
Re: [Chicken-hackers] [PATCH] Improve Chicken's handling of numerical syntax |
Date: |
Tue, 13 Sep 2011 15:14:14 -0400 |
User-agent: |
Mutt/1.5.18 (2008-05-17) |
Peter Bex scripsit:
> While hacking on it I found some code for OpenBSD and Windows to
> handle "nan" and "inf" syntaxes. If I understand correctly these
> systems do not handle these in their libc's strtod() function.
Indeed, some older versions of glibc don't do well with them either.
> I believe this may actually cause compatibility problems between
> Chickens running on different OSes; some Chickens accept "+NaN" as
> valid input, while those running on Windows or OpenBSD (probably?)
> don't. Depending on libc, Chicken might even serialize these values
> in an incompatible way such that others don't accept it.
That's just what happens: in this case, portability is more important
than backward compatibility, I think.
> To do this, there's an ugly bit of code in the attached patch which
> adds a check in convert_string_to_number() for the strings "+nan.0"
> "-nan.0", "+inf.0" and "-inf.0", case insensitively. This conforms
> to R6RS, and most likely will end up as official R7RS syntax as well
> (there's still a proposal up in the air to make infinity represented
> by "1/0").
That proposal was voted down. In addition, "-0.0" should be
special-cased. Similarly, on all platforms number-to-string conversion
should bypass the C library and generate "+nan.0", "+inf.0", "-inf.0",
and "-0.0" for the appropriate values.
> Let's get the basic number parsing correct first!
Amen.
--
Knowledge studies others / Wisdom is self-known; John Cowan
Muscle masters brothers / Self-mastery is bone; address@hidden
Content need never borrow / Ambition wanders blind; http://ccil.org/~cowan
Vitality cleaves to the marrow / Leaving death behind. --Tao 33 (Bynner)