GNU bug report logs - #11887
string->number edge cases

Previous Next

Package: guile;

Reported by: Ian Price <ianprice90 <at> googlemail.com>

Date: Mon, 9 Jul 2012 12:36:01 UTC

Severity: normal

Done: Mark H Weaver <mhw <at> netris.org>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Peter Bex <Peter.Bex <at> xs4all.nl>
To: Mark H Weaver <mhw <at> netris.org>
Cc: Andy Wingo <wingo <at> pobox.com>, Ian Price <ianprice90 <at> googlemail.com>, 11887 <at> debbugs.gnu.org
Subject: bug#11887: string->number edge cases
Date: Tue, 5 Mar 2013 20:14:26 +0100
On Tue, Mar 05, 2013 at 02:04:55PM -0500, Mark H Weaver wrote:
> FYI, I produced a simple patch a while back to fix this (see below), but
> it had an interesting side effect: it caused the reader to read things
> like "3/0" and "4+3/0i" as symbols.  More generally, anything for which
> 'scm_string_to_number' returns false is treated as a symbol by 'read'.

I think this is simple and at least internally consistent.  Several
Schemes assume something like 1/0 is a symbol; Chicken does this as
well, with the numbers egg loaded, so does Gambit.

Raising an error is also acceptable.  According to the lexical syntax
1/0 *is* a valid number, so you could argue that it *must* parse as
a number, which is impossible so an error should occur.

This is also related to how string->number deals with it; if it
returns #f it is essentially saying "this is not valid numerical syntax"
and should fail to parse as a number.  Not raising an exception on
(string->number "1/0) but raising an exception on
(with-input-from-string "1/0" read) is a bit odd, I'd say.

Cheers,
Peter
-- 
http://www.more-magic.net




This bug report was last modified 12 years and 160 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.