<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/4.2.2">
</HEAD>
<BODY>
Hi the list,<BR>
I was wondering for my midi/osc -> event mapping project if it was possible to put objects instances (with racket/class) as hash keys.<BR>
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.<BR>
<BR>
For the record:<BR>
<BR>
(require racket/class)<BR>
<BR>
(define test%<BR>
(class object%<BR>
(inspect #f)<BR>
(init-field<BR>
address<BR>
)<BR>
(define/public (getAddress)<BR>
address<BR>
)<BR>
(define/public (setAddress n)<BR>
(set! address n)<BR>
)<BR>
(super-new)<BR>
)<BR>
)<BR>
<BR>
(define testy (new test% (address 12)))<BR>
(define testH (make-hash))<BR>
(hash-set! testH testy (send testy getAddress))<BR>
<BR>
> testH<BR>
#hash((#(struct:object:test% 12) . 12))<BR>
<BR>
> (send testy setAddress 13)<BR>
> testH<BR>
#hash((#(struct:object:test% 13) . 12))<BR>
> (hash-has-key testH testy)<BR>
#f<BR>
> (hash-ref testH testy)<BR>
hash-ref: no value found for key: (object:test% 13)<BR>
<BR>
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.<BR>
<BR>
Thanks in advance.<BR>
<BR>
Ted
</BODY>
</HTML>