chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] hash table question


From: felix
Subject: Re: [Chicken-users] hash table question
Date: Sun, 04 Aug 2002 22:29:42 +0200

Peter Keller wrote:
> 
> Hello,
> 
> I have a question about the hash tables that chicken implements.
> 
> Suppose I do this:
> 
> >>> Linux black > csi
> ; This is the CHICKEN interpreter - Version 0, Build 1072 - linux-unix-gnu-x86
> ; (c)2000-2002 Felix L. Winkelmann
> >>> (define foo (make-hash-table))
> >>> (hash-table-set! foo "foobar" 0)
> >>> (hash-table-ref foo "foobar")
> #f
> 
> This seems like a natural thing for me to do, but since the hash tables use
> eq? to do the compare, it will fail since (eq? "foobar" "foobar") is defined
> to fail.
> 
> My question is, why is it like this? Is there any way to control the equality
> function or the hashing algorithm?
> 
> Suppose I want to replace eq? with equal?.
> 

Currently the hashtables use eq? comparison for keys purely out
of performance-reasons. The eq? test can be done in-line, so no
CPS-call is needed (which is relatively expensive). On the other
hand one could code a fast-path for eq? comparison and fall back
to a slow but generic version for other comparisons.

Something along the lines of "(make-hash-table [PRED [SIZE]])"is
probably
best.

I will take a look and keep you posted.
Thanks for the suggestion.


cheers,
felix



reply via email to

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