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

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Mon Jul 28 16:30:32 EDT 2008

Yes, that's a bug in `equal?' or in transparent records, depending on
your perspective.

I've fixed the bug in SVN, and I've taken the liberty of adding your
tests to the R6RS test suite.

Thanks!
Matthew

At Mon, 28 Jul 2008 14:33:28 -0500, Alan Watson wrote:
> 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/
> 
> _________________________________________________
>   For list-related administrative tasks:
>   http://list.cs.brown.edu/mailman/listinfo/plt-scheme


Posted on the users mailing list.