[plt-scheme] 'equal hashes don't survive serialization

From: George Herson (gherson at snet.net)
Date: Wed Mar 7 18:06:36 EST 2007

Danny, thanks alot and sorry: false alarm.  Whatever
problem/confusion i had evaporated somehow.  I'm able
to correctly deserialize 'equal hash tables from file,
which is great.

George
--- Daniel Yoo <dyoo at cs.wpi.edu> wrote:

> 
> 
> > When I use the serialize.ss library to serialize
> my hash tables that 
> > were created to use equal? to compare keys, the
> hash tables deserialize 
> > with eq? as the key-comparison mode.  How do I
> avoid this?  With eq? as 
> > the key-comparison mode, a look up with a key as
> simple as '(2) won't 
> > work, I found.
> 
> Hi George,
> 
> 
> That's unusual!  Let me check something.
> 
>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> dyoo at dyoo-desktop:~$ local/plt-360/bin/mzscheme
> Welcome to MzScheme version 360, Copyright (c)
> 2004-2006 PLT Scheme Inc.
> > (require (lib "serialize.ss"))
> >
> > (hash-table? (deserialize (serialize
> (make-hash-table 'equal))) 'equal)
> #t
> >
> > (hash-table? (deserialize (serialize
> (make-hash-table))) 'equal)
> #f
> >
> > (define ht (make-hash-table 'equal))
> > (hash-table-put! ht '(2) "two")
> > (define refreshed-ht (deserialize (serialize ht)))
> > (hash-table-get refreshed-ht (cons 2 '()))
> "two"
>
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> 
> 
> serialize.ss should preserve the flags that the hash
> table was constructed 
> with.  I did a scan through the source code, and
> didn't see anything 
> unusual.  The example above looks like it works as
> expected.
> 
> 
> There might be something going on here, since you're
> running into 
> problems.  Do you have an example we can test out to
> see if we can 
> duplicate the behavior you're seeing?
> 
> 
> Best of wishes!
> 



Posted on the users mailing list.