>From 8e63e256061fc77b00c27e6891e14f7570387b81 Mon Sep 17 00:00:00 2001 From: Peter Bex Date: Wed, 21 Mar 2012 22:16:59 +0100 Subject: [PATCH] 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) --- library.scm | 31 +++++++++++++++---------------- 1 files changed, 15 insertions(+), 16 deletions(-) diff --git a/library.scm b/library.scm index cc84da1..52dcce0 100644 --- a/library.scm +++ b/library.scm @@ -2580,23 +2580,22 @@ EOF (define (r-number radix exactness) (set! rat-flag #f) - (let ([tok (r-token)]) + (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)] ) ) ] ) ) ) + ((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)) -- 1.7.9.1