[plt-scheme] struct-eqv?

From: Felix Klock's PLT scheme proxy (pltscheme at pnkfx.org)
Date: Tue Mar 10 22:01:57 EDT 2009

On Mar 10, 2009, at 8:47 PM, Matthew Flatt wrote:

> If you want to keep a structure type opaque, you can specialize
> `equal?' by implementing the `prop:equal+hash' property:
>
> (define-struct point (x y)
>   #:property prop:equal+hash
>              (list
>               (lambda (a b equal?-recur)
>                 (and (equal?-recur (point-x a) (point-x b))
>                      (equal?-recur (point-y a) (point-y b))))
>               (lambda (a hash-code-recur)
>                 (+ (hash-code-recur (point-x a))
>                    (* 3 (hash-code-recur (point-x b)))))
>               (lambda (a hash2-code-recur)
>                 (+ (hash2-code-recur (point-x a))
>                    (hash2-code-recur (point-x b))))))

The example above has some typo's; e.g. note that b is not in scope in  
the latter two lambda expressions.

I suspect that Matthew intended to write (point-y a) in the two latter  
places where he has written (point-x b).

-Felix




Posted on the users mailing list.