[racket] objects as hash keys

From: Ted (tedr56 at gmail.com)
Date: Fri Oct 19 11:57:41 EDT 2012

Hi the list,
I was wondering for my midi/osc -> event mapping project if it was
possible to put objects instances (with racket/class) as hash keys.
I tried and it worked. The problem is, I pushed further and when I
change object fields, the hash can't find my key anymore, despite I see
it in.

For the record:

(require racket/class)

(define test%
    (class object%
        (inspect #f)
        (define/public (getAddress)
        (define/public (setAddress n)
            (set! address n)

(define testy (new test% (address 12)))
(define testH (make-hash))
(hash-set! testH testy (send testy getAddress))

> testH
#hash((#(struct:object:test% 12) . 12))

> (send testy setAddress 13)
> testH
#hash((#(struct:object:test% 13) . 12))
> (hash-has-key testH testy)
> (hash-ref testH testy)
hash-ref: no value found for key: (object:test% 13)

That's an odd response. I know it's an odd request too, but if anyone
could help me on this, even it I have to use an other solution.

Thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121019/8e0d57f5/attachment.html>

Posted on the users mailing list.