I guess this is actually a better behavior, because the symbol
returned by gensym is not interned so that it can't be eq? to
the symbols with the same name. The default hash function uses
a pointer of the symbol to calculate the hash value, which prevents
you from looking up by the quoted symbol.
The confusing point is that the symbol from gensym and the quoted
symbol can be equal?-equivalent. Is that a feature?
The workaround may be to define your own hash function which uses
symbol name to calculate hash value, like this:
STk> (define (my-hash v)
(if (symbol? v)
(hash-table-hash (symbol->string v))
(hash-table-hash v)))
my-hash
STk> (define s (gensym "abc"))
s
STk> s
abc2
STk> (my-hash s)
79592
STk> (my-hash 'abc2)
79592
STk> (define h (make-hash-table equal? my-hash))
h
STk> (hash-table-put! h s 6)
STk> (hash-table-get h s)
6
STk> (hash-table-get h 'abc2)
6
STk>
--
Shiro KAWAI
Square USA Inc. Honolulu Studio R&D division
#"The most important things are the hardest things to say" --- Stephen King
Received on Sun Sep 12 1999 - 06:06:59 CEST