~ chicken-core (chicken-5) cdfa2279e57f036f9aa35aad6d1ceedc7f7b5555
commit cdfa2279e57f036f9aa35aad6d1ceedc7f7b5555
Author: Peter Bex <peter.bex@xs4all.nl>
AuthorDate: Wed Mar 21 22:16:59 2012 +0100
Commit: Christian Kellermann <ckeen@pestilenz.org>
CommitDate: Mon Mar 26 11:07:01 2012 +0200
Only emit warning about not being able to represent exact fractions when the user asked for an exact value and we couldn't deliver (example: #i1/2 should just return 0.5 without warnings)
Signed-off-by: Christian Kellermann <ckeen@pestilenz.org>
diff --git a/library.scm b/library.scm
index c85c98a2..030fad80 100644
--- a/library.scm
+++ b/library.scm
@@ -2583,23 +2583,22 @@ EOF
(define (r-number radix exactness)
(set! rat-flag #f)
- (let ([tok (r-token)])
- (cond
- [(string=? tok ".")
- (##sys#read-error port "invalid use of `.'")]
- [(and (fx> (##sys#size tok) 0) (char=? (string-ref tok 0) #\#))
- (##sys#read-error port "unexpected prefix in number syntax" tok)]
- [else
- (let ([val (##sys#string->number tok (or radix 10) exactness)] )
- (cond [val
- ;;XXX move this into ##sys#string->number ?
- (when (and (##sys#inexact? val) rat-flag)
- (##sys#read-warning
- port
- "cannot represent exact fraction - coerced to flonum" tok) )
- val]
- [radix (##sys#read-error port "illegal number syntax" tok)]
- [else (build-symbol tok)] ) ) ] ) ) )
+ (let ((tok (r-token)))
+ (cond
+ ((string=? tok ".")
+ (##sys#read-error port "invalid use of `.'"))
+ ((and (fx> (##sys#size tok) 0) (char=? (string-ref tok 0) #\#))
+ (##sys#read-error port "unexpected prefix in number syntax" tok))
+ (else
+ (let ((val (##sys#string->number tok (or radix 10) exactness)) )
+ (cond (val
+ (when (and (##sys#inexact? val) (not (eq? exactness 'i)) rat-flag)
+ (##sys#read-warning
+ port
+ "cannot represent exact fraction - coerced to flonum" tok) )
+ val)
+ (radix (##sys#read-error port "illegal number syntax" tok))
+ (else (build-symbol tok)) ) ) ) ) ) )
(define (r-number-with-exactness radix)
(cond [(char=? #\# (##sys#peek-char-0 port))
Trap