chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Hash table equality pitfall


From: Peter Bex
Subject: Re: [Chicken-users] Hash table equality pitfall
Date: Thu, 1 Mar 2012 19:01:49 +0100
User-agent: Mutt/1.4.2.3i

On Thu, Mar 01, 2012 at 12:03:25PM -0500, John Cowan wrote:
> In addition, the following Schemes support SRFI-69 with `equal?`
> descending into hash tables:  Kawa, Chibi.

What does this mean in practice?  Do they do a "dumb" comparison like
Chicken does (ie, producing different results depending on the insertion
order) or do they check whether the hash tables have exactly the same
keys, each with identical corresponding values?

If they do it "correctly", how do they deal with differences in initial
bucket size, and what do they do with hash tables having identical
key/values but different hashing or different comparison procedures?

> I think the main reason SRFI 69 doesn't have much support is its fairly
> recent date (2005).  It would probably be straightforward to layer it
> over the native support in most Schemes, but people haven't bothered to
> do so.

That's rather odd, considering there were quite a few people discussing
it, judging by the SRFI discussion archive (not as much as some other
SRFIs, but still a few).  It's also a very useful thing to have.
I guess that's just a Chickeneer's way of looking at it :)

> In addition, the reference implementation is more of a proof of
> concept than a drop-in implementation like those provided with SRFI-1,
> SRFI-2, SRFI-43, etc.

Why is it not drop-in?  Maybe I'm missing something, but from a quick
glance the implementation doesn't really look too different from
Chicken's implementation, conceptually.

> > Luckily, with the new version the mistake of thinking that equal?
> > is defined for hash-tables is a lot harder to make since the
> > randomization factor will ensure they are almost always different.
> 
> I think that's good.  The behavior of `equal?` is primarily historical
> anyway; people can and should write their own equivalence predicates to
> solve their own problems.

You could easily argue either way, but it's good that it doesn't seem to
be correct when you first try it.

Cheers,
Peter
-- 
http://sjamaan.ath.cx
--
"The process of preparing programs for a digital computer
 is especially attractive, not only because it can be economically
 and scientifically rewarding, but also because it can be an aesthetic
 experience much like composing poetry or music."
                                                        -- Donald Knuth



reply via email to

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