<!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 -&gt; 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>
&nbsp;&nbsp;&nbsp; (class object%<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (inspect #f)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (init-field<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; address<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (define/public (getAddress)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; address<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (define/public (setAddress n)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (set! address n)<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; )<BR>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (super-new)<BR>
&nbsp;&nbsp;&nbsp; )<BR>
)<BR>
<BR>
(define testy (new test% (address 12)))<BR>
(define testH (make-hash))<BR>
(hash-set! testH testy (send testy getAddress))<BR>
<BR>
&gt; testH<BR>
#hash((#(struct:object:test% 12) . 12))<BR>
<BR>
&gt; (send testy setAddress 13)<BR>
&gt; testH<BR>
#hash((#(struct:object:test% 13) . 12))<BR>
&gt; (hash-has-key testH testy)<BR>
#f<BR>
&gt; (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>