[plt-scheme] Possible bug in equal? applied to records

From: Alan Watson (alan at alan-watson.org)
Date: Mon Jul 28 15:33:28 EDT 2008

According to my reading of §11.5 of the R6RS, the following procedure  
should always return #t for any x and y:

(define (check-equal x y)
   (eq? (eqv? x y)
        (equal? (list x) (list y))))

However, in the following case it returns #f:

(define-record-type (tag make-tag tag?))
(check-equal (make-tag) (make-tag))

It returns #t if I define the record type to be opaque. I append a  
complete R6RS program that shows this behaviour.

Is this a bug in the R6RS mode of PLT Scheme or an error in my  
understanding of the R6RS?

Regards,

Alan

Here is a complete R6RS program that demonstrates the behaviour I  
mention above. Running this program in version 4.0.2 of DrScheme with  
the Module language produces #f, #f, #t, and #t.

#!r6rs

(import (rnrs base (6))
         (rnrs records syntactic (6))
         (rnrs io simple (6)))

(define (check-equal x y)
   (eq? (eqv? x y)
        (equal? (list x) (list y))))

(define-record-type (tag make-tag tag?))
(write (check-equal (make-tag) (make-tag)))
(newline)

(define-record-type (tag-s make-tag-s tag-s?)
   (sealed #t))
(write (check-equal (make-tag-s) (make-tag-s)))
(newline)

(define-record-type (tag-o make-tag-o tag-o?)
   (opaque #t))
(write (check-equal (make-tag-o) (make-tag-o)))
(newline)

(define-record-type (tag-so make-tag-so tag-so?)
   (sealed #t)
   (opaque #t))
(write (check-equal (make-tag-so) (make-tag-so)))
(newline)

-- 
Alan Watson
http://www.alan-watson.org/



Posted on the users mailing list.