[plt-scheme] Pointers and hashing

From: Thomas Chust (chust at web.de)
Date: Fri Jan 15 19:10:26 EST 2010

Hello,

I'm coding a Scheme interface to a C library and have used structures
containing a native pointer plus some additional cached information as
wrappers for a certain type of native objects. I want these structures
to compare equal? if they contain the same pointer, so I set a
prop:equal+hash property on the structure type but now I wonder how to
implement the hashing functions that, of course, should be consistent
with the equality predicate: Pointers to the same address don't
necessarily compare equal? and I didn't find any predefined procedure to
compute a hash code in agreement with ptr-equal?.

Is there any sane way to compute such a hash code or do I really have to
write the pointer into some memory cell, read it back as an integer and
work with that value? It feels so C, I don't want to do that ;-)

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


Posted on the users mailing list.