No subject

From: ()
Date: Fri Jul 13 09:02:16 EDT 2012

Caveat concerning mutable keys: If a key in an equal?-based hash table is  
mutated (e.g., a key string is modified with string-set!), then the hash  
table’s behavior for insertion and lookup operations becomes unpredictable.

Try make-hasheq instead of make-hash, that should work here.

On Fri, 19 Oct 2012 17:57:41 +0200, Ted &lt;<A HREF="mailto:tedr56 at">tedr56 at</A>&gt; wrote:

&gt; Hi the list,
&gt; I was wondering for my midi/osc -&gt; event mapping project if it was
&gt; possible to put objects instances (with racket/class) as hash keys.
&gt; I tried and it worked. The problem is, I pushed further and when I
&gt; change object fields, the hash can't find my key anymore, despite I see
&gt; it in.
&gt; For the record:
&gt; (require racket/class)
&gt; (define test%
&gt;     (class object%
&gt;         (inspect #f)
&gt;         (init-field
&gt;             address
&gt;         )
&gt;         (define/public (getAddress)
&gt;             address
&gt;         )
&gt;         (define/public (setAddress n)
&gt;             (set! address n)
&gt;         )
&gt;         (super-new)
&gt;     )
&gt; )
&gt; (define testy (new test% (address 12)))
&gt; (define testH (make-hash))
&gt; (hash-set! testH testy (send testy getAddress))
&gt;&gt; testH
&gt; #hash((#(struct:object:test% 12) . 12))
&gt;&gt; (send testy setAddress 13)
&gt;&gt; testH
&gt; #hash((#(struct:object:test% 13) . 12))
&gt;&gt; (hash-has-key testH testy)
&gt; #f
&gt;&gt; (hash-ref testH testy)
&gt; hash-ref: no value found for key: (object:test% 13)
&gt; That's an odd response. I know it's an odd request too, but if anyone
&gt; could help me on this, even it I have to use an other solution.
&gt; Thanks in advance.
&gt; Ted

  Racket Users list:
  <A HREF=""></A>


Posted on the users mailing list.