[plt-scheme] Deserialization error
On Feb 10, 2009, at 12:42 PM, M. Fatih Köksal wrote:
> Hi again,
>
> After the discussion on "Log every change in Definitions and
> Interactions"[1] mails, we started to implement the screen-replay
> tool.
> We are facing some problems while deserializing our structure;
>
> We have this serializable structure exported by record.ss
>
> (module record mzscheme
> (require scheme/serialize)
> (provide record make-record record-timestamp record-operation
> record-start record-len record-content)
> (define-serializable-struct record (timestamp operation start len
> content)))
>
> Then we serialize the keystrokes and write it to a file
>
> ...
>
> (define (serialize-record rec)
> (with-output-to-file
> "/tmp/fatih.record"
> (lambda ()
> (begin (display (serialize rec))
> (display "\n")))
> 'binary
> 'append))
> ...
>
> Here are some example lines from the file fatih.record;
>
> ((1) 1 (((lib screen-replay/record.ss) . deserialize-info:record-
> v0)) 0
> () () (0 1234286023 insert 0 1 (u . a)))
> ((1) 1 (((lib screen-replay/record.ss) . deserialize-info:record-
> v0)) 0
> () () (0 1234286023 insert 1 1 (u . s)))
> ((1) 1 (((lib screen-replay/record.ss) . deserialize-info:record-
> v0)) 0
> () () (0 1234286024 insert 2 1 (u . d)))
>
> We are able to read the lines from the file, but deserializing gives
> this error;
>
>> (deserialize (with-input-from-file "/tmp/fatih.record" read 'binary))
>
> standard-module-name-resolver: expected argument of type <module-
> path or
> path>; given
> "/home/fkoksal/.plt-scheme/4.0.1/collects/screen-replay/record.ss"
>
>
> Any comments?
This looks to me like a bug in the serialize library.
Prefab structs might solve your problem more simply, since they're
automatically readable and writable, so they avoid the complicated
serialization mechanism. Search the help desk for "prefab". Here's
roughly what the code would look like:
(module record mzscheme
;; replace mzscheme's define-struct with scheme/base's
(require (only scheme/base define-struct))
(define-struct record (timestamp operation start len content)
#:prefab)
___)
Ryan