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: Mark H Weaver <mhw <at> netris.org>
To: Daniel Llorens <daniel.llorens <at> bluewin.ch>
Cc: 11887 <at> debbugs.gnu.org
Subject: bug#11887: string->number edge cases
Date: Wed, 06 Mar 2013 11:55:30 -0500
Daniel Llorens <daniel.llorens <at> bluewin.ch> writes:

> I think this isn't working as it should either.
>
> scheme@(guile-user)> +1i
> $1 = 0.0+1.0i
> scheme@(guile-user)> 1i
> ;;; <unknown-location>: warning: possibly unbound variable `#{1i}#'
> ERROR: In procedure #<procedure 101d6d4a0 ()>:
> ERROR: In procedure module-lookup: Unbound variable: #{1i}#

No, this is correct.  Scheme requires a sign before an imaginary part.
See R5RS section 7.1.1 (Lexical structure).

    Thanks,
      Mark


--8<---------------cut here---------------start------------->8---
  <number> -> <num 2>| <num 8>
       | <num 10>| <num 16>
  
  The following rules for <num R>, <complex R>, <real R>, <ureal R>,
  <uinteger R>, and <prefix R> should be replicated for R = 2, 8, 10,
  and 16.  There are no rules for <decimal 2>, <decimal 8>, and <decimal
  16>, which means that numbers containing decimal points or exponents
  must be in decimal radix.
  
  <num R> -> <prefix R> <complex R>
  <complex R> -> <real R> | <real R> @ <real R>
      | <real R> + <ureal R> i | <real R> - <ureal R> i
      | <real R> + i | <real R> - i
      | + <ureal R> i | - <ureal R> i | + i | - i
  <real R> -> <sign> <ureal R>
  <ureal R> -> <uinteger R>
      | <uinteger R> / <uinteger R>
      | <decimal R>
  <decimal 10> -> <uinteger 10> <suffix>
      | . <digit 10>+ #* <suffix>
      | <digit 10>+ . <digit 10>* #* <suffix>
      | <digit 10>+ #+ . #* <suffix>
  <uinteger R> -> <digit R>+ #*
  <prefix R> -> <radix R> <exactness>
      | <exactness> <radix R>
  
  <suffix> -> <empty>
      | <exponent marker> <sign> <digit 10>+
  <exponent marker> -> e | s | f | d | l
  <sign> -> <empty>  | + |  -
  <exactness> -> <empty> | #i | #e
  <radix 2> -> #b
  <radix 8> -> #o
  <radix 10> -> <empty> | #d
  <radix 16> -> #x
  <digit 2> -> 0 | 1
  <digit 8> -> 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7
  <digit 10> -> <digit>
  <digit 16> -> <digit 10> | a | b | c | d | e | f
--8<---------------cut here---------------end--------------->8---




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.