Fix bug in eqv? and equal? by which = numbers represented differently
authorHal Abelson <edu/mit/hal>
Thu, 31 Jan 1991 07:08:51 +0000 (07:08 +0000)
committerHal Abelson <edu/mit/hal>
Thu, 31 Jan 1991 07:08:51 +0000 (07:08 +0000)
(eg. fixnum vs. bignum) were deemed unequal.

v7/src/runtime/equals.scm

index acd433f82dcfc579407700dd06c8da89ab6d6392..50ff0c43daf64c28142ea1f9634272d1802be729 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/equals.scm,v 14.2 1989/10/26 06:46:03 cph Rel $
+$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/equals.scm,v 14.3 1991/01/31 07:08:51 hal Exp $
 
 Copyright (c) 1988, 1989 Massachusetts Institute of Technology
 
@@ -42,35 +42,43 @@ MIT in each case. |#
   ;; numbers specially, but it turns out that EQ? does the right thing
   ;; for everything but numbers, so we take advantage of that.
   (or (eq? x y)
-      (and (object-type? (object-type x) y)
-          (if (number? y)
-              (and (= x y)
-                   (boolean=? (exact? x) (exact? y)))
-              (and (object-type? (ucode-type vector) y)
-                   (zero? (vector-length x))
-                   (zero? (vector-length y)))))))
+      (if (object-type? (object-type x) y)
+         (if (number? y)
+             (and (= x y)
+                  (boolean=? (exact? x) (exact? y)))
+             (and (object-type? (ucode-type vector) y)
+                  (zero? (vector-length x))
+                  (zero? (vector-length y))))
+         (and (number? x)
+              (number? y)
+              (= x y)
+              (boolean=? (exact? x) (exact? y))))))
 
 (define (equal? x y)
   (or (eq? x y)
-      (and (object-type? (object-type x) y)
-          (cond ((number? y)
-                 (and (= x y)
-                      (boolean=? (exact? x) (exact? y))))
-                ((object-type? (ucode-type list) y)
-                 (and (equal? (car x) (car y))
-                      (equal? (cdr x) (cdr y))))
-                ((object-type? (ucode-type vector) y)
-                 (let ((size (vector-length x)))
-                   (and (= size (vector-length y))
-                        (let loop ((index 0))
-                          (or (= index size)
-                              (and (equal? (vector-ref x index)
-                                           (vector-ref y index))
-                                   (loop (1+ index))))))))
-                ((object-type? (ucode-type cell) y)
-                 (equal? (cell-contents x) (cell-contents y)))
-                ((object-type? (ucode-type character-string) y)
-                 (string=? x y))
-                ((object-type? (ucode-type vector-1b) y)
-                 (bit-string=? x y))
-                (else false)))))
\ No newline at end of file
+      (if (object-type? (object-type x) y)
+         (cond ((number? y)
+                (and (= x y)
+                     (boolean=? (exact? x) (exact? y))))
+               ((object-type? (ucode-type list) y)
+                (and (equal? (car x) (car y))
+                     (equal? (cdr x) (cdr y))))
+               ((object-type? (ucode-type vector) y)
+                (let ((size (vector-length x)))
+                  (and (= size (vector-length y))
+                       (let loop ((index 0))
+                         (or (= index size)
+                             (and (equal? (vector-ref x index)
+                                          (vector-ref y index))
+                                  (loop (1+ index))))))))
+               ((object-type? (ucode-type cell) y)
+                (equal? (cell-contents x) (cell-contents y)))
+               ((object-type? (ucode-type character-string) y)
+                (string=? x y))
+               ((object-type? (ucode-type vector-1b) y)
+                (bit-string=? x y))
+               (else false))
+         (and (number? x)
+              (number? y)
+              (= x y)
+              (boolean=? (exact? x) (exact? y))))))
\ No newline at end of file