[plt-scheme] equal? for native extension types [patch]
On Tue, 13 Feb 2007, Dimitris Vyzovitis wrote:
> equal? knows about some built-in types and structs -- and that's about
> it. If you happen to define extension types with meaningful equality
> tests, then you are stuck. Quite frustrating.
Hi Dimitris,
If structures are transparent, by setting their inspector appropriately,
then equal? will work on them.
For example:
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> (define-struct dummy (val) #f)
> (define x1 (make-dummy 1))
> (define x2 (make-dummy 2))
> (define x3 (make-dummy 1))
> (equal? x1 x3)
#t
> (equal? x1 x2)
#f
> (eq? x1 x3)
#f
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
See:
http://download.plt-scheme.org/doc/360/html/mzscheme/mzscheme-Z-H-4.html#node_sec_4.8
and:
http://download.plt-scheme.org/doc/360/html/mzscheme/mzscheme-Z-H-4.html#node_sec_4.5
Best of wishes!