chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] Hashtable is behaving unexpectedly


From: Felix Winkelmann
Subject: Re: [Chicken-users] Hashtable is behaving unexpectedly
Date: Thu, 30 Sep 2004 11:31:42 +0200
User-agent: Mozilla Thunderbird 0.5 (X11/20040208)

Michael Erdmann wrote:

Dear all the code fragement below works as expected:

(define h (make-hash-table))

(define A_Age 'Age)
(define Michael "Michael")

(put! h Michael A_Age 45)
(write (get h Michael A_Age )) (newline)
(write (hash-table-ref h Michael)) (newline)

(write (hash-table->list h)) (newline)
address@hidden:~/scheme/x> ./ht
45
((Age . 45))
(("Michael" (Age . 45)))

_but_ when i am replacing Michael by "Michael" every where
where i invoke get it fails. Probly because they are not
the same objects.

Why is it like this implemented? It is not very helpfull
in this implementation, or did i miss something?

It depends on the comparison function used by the hash-table.
The default is eqv?, but you can pass the desired function
to make-hash-table:

(define h (make-hash-table string=?))

eqv? is more efficient, so it is the default.

cheers,
felix




reply via email to

[Prev in Thread] Current Thread [Next in Thread]