unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Peter Bex <Peter.Bex@xs4all.nl>
To: Mark H Weaver <mhw@netris.org>
Cc: Ian Price <ianprice90@googlemail.com>, 11887@debbugs.gnu.org
Subject: bug#11887: string->number edge cases
Date: Tue, 5 Mar 2013 20:14:26 +0100	[thread overview]
Message-ID: <20130305191426.GJ4379@frohike.xs4all.nl> (raw)
In-Reply-To: <878v61ekh4.fsf@tines.lan>

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





  reply	other threads:[~2013-03-05 19:14 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-09 12:29 bug#11887: string->number edge cases Ian Price
2013-03-05 14:49 ` Andy Wingo
2013-03-05 19:04   ` Mark H Weaver
2013-03-05 19:14     ` Peter Bex [this message]
2013-03-06 18:11       ` Mark H Weaver
2013-03-06 18:15       ` bug#11887: [PATCH] Improve standards conformance of string->number (was Re: bug#11887: string->number edge cases) Mark H Weaver
2013-03-07 20:47         ` Mark H Weaver
2013-03-05 19:06   ` bug#11887: string->number edge cases Peter Bex
     [not found] <mailman.1167569.1362509701.854.bug-guile@gnu.org>
2013-03-05 20:33 ` Daniel Llorens
2013-03-06 16:55   ` Mark H Weaver
2013-03-06 17:11     ` Daniel Llorens

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20130305191426.GJ4379@frohike.xs4all.nl \
    --to=peter.bex@xs4all.nl \
    --cc=11887@debbugs.gnu.org \
    --cc=ianprice90@googlemail.com \
    --cc=mhw@netris.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).