From f652f17645324f336b12db8c9e86706ab41ff2ec Mon Sep 17 00:00:00 2001 From: Hal Abelson Date: Thu, 31 Jan 1991 07:08:51 +0000 Subject: [PATCH] Fix bug in eqv? and equal? by which = numbers represented differently (eg. fixnum vs. bignum) were deemed unequal. --- v7/src/runtime/equals.scm | 68 ++++++++++++++++++++++----------------- 1 file changed, 38 insertions(+), 30 deletions(-) diff --git a/v7/src/runtime/equals.scm b/v7/src/runtime/equals.scm index acd433f82..50ff0c43d 100644 --- a/v7/src/runtime/equals.scm +++ b/v7/src/runtime/equals.scm @@ -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 -- 2.25.1