[prev in list] [next in list] [prev in thread] [next in thread] 

List:       racket-users
Subject:    [plt-scheme] 'equal hashes don't survive serialization
From:       dyoo () cs ! wpi ! edu (Daniel Yoo)
Date:       2007-02-25 21:43:23
Message-ID: Pine.LNX.4.63.0702251636010.3715 () cs ! wpi ! edu
[Download RAW message or body]



> 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!


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic