[racket] hash table confusion

From: Manfred Lotz (manfred.lotz at arcor.de)
Date: Sat Dec 28 17:31:06 EST 2013

On Sat, 28 Dec 2013 17:15:25 -0500 (EST)
"J. Ian Johnson" <ianj at ccs.neu.edu> wrote:

> You want to make sure your structs are inspectable. You can define
> your structs with the #:transparent option or define your own
> equality relation with the gen:equal+hash generic interface. -Ian


Aah, ok I got it. In my source with the hash table I indeed used
#:transparent which made equal? work as I expected. 

Thanks for clarifying.

-- 
Manfred



> ----- Original Message ----- From: Manfred Lotz
> <manfred.lotz at arcor.de> To:
> users at racket-lang.org Sent: Sat, 28 Dec 2013
> 15:41:28 -0500 (EST) Subject: [racket] hash table confusion
> 
> I have a hash table (created by using make-hash) where the key is a
> struct. This seems to work fine although the documentation says
>    The make-hash procedure creates a table where keys are compared
> with equal?,...
> 
> and it seems that equal? gives #f if I compare two structs having the
> same contents:
> 
> 
> (struct cpd (x y))
> 
> (define C1 (cpd 1 "bla"))
> (define C2 (cpd 1 "bla"))
> 
> (equal? C1 C2)
> #f
> 
> 
> Why does my hash table work fine? In my hash handling I'm using
> make-hash, hash-ref!, hash-set!, hash-for-each.
> 




Posted on the users mailing list.