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: Michael Erdmann
Subject: Re: [Chicken-users] Hashtable is behaving unexpectedly
Date: Thu, 30 Sep 2004 18:17:22 +0200
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7) Gecko/20040616

Thanks,

i am realy sorry for this. I found i out my self in a quiet
moment reading again the docu.

Any way i find the default value very strange since the
typical use case will not be to put in the same object
into the hashtable returning prevuously stored data for
the same object.

Michael


Felix Winkelmann wrote:
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]