On 11 Jul 2000, bernard URBAN wrote:

> # guile
> guile> (version)
> "1.4"
> guile> (expt 2 -1)
> ERROR: In procedure integer-expt:
> ERROR: Argument out of range: -1
> ABORT: (out-of-range)
> guile> ($expt 2 -1)
> 0.5
> guile> 
> 
> >From boot-9.scm:
> (define expt
>   (let ((integer-expt integer-expt))
>     (lambda (z1 z2)
>       (cond ((exact? z2)
>            (integer-expt z1 z2))
>           ((and (real? z2) (real? z1) (>= z1 0))
>            ($expt z1 z2))
>           (else
>            (exp (* z2 (log z1))))))))

The test for exactness if wrong here:  Rationals (if supported) could
fulfill that predicate as well.  I will apply the following patch:

diff -u -r1.208 boot-9.scm
--- boot-9.scm  2000/07/01 17:01:22     1.208
+++ boot-9.scm  2000/07/12 07:23:07
@@ -793,7 +793,7 @@
 (define expt
   (let ((integer-expt integer-expt))
     (lambda (z1 z2)
-      (cond ((exact? z2)
+      (cond ((and (integer? z2) (>= z2 0))
             (integer-expt z1 z2))
            ((and (real? z2) (real? z1) (>= z1 0))
             ($expt z1 z2))

> I noticed also that list-tail does no longer accept a second negative
> argument. R5RS say it is an error if the list length is shorter
> than the second argument, but is silent for the negative case.

But the example implementation given in R5RS relies on the fact that the
parameter is positive or zero.  Further, I can not think of any reasonable
behaviour for the case of negative indexes.  Thus, IMO it is a bug fix
rather than a bug that negative indexes are not accepted.

Best regards
Dirk

Reply via email to