[racket] serializing/deserializing structs (and read/writing them over ports)

From: Dominick LoBraico (dj+racket at lobraico.com)
Date: Fri Oct 5 00:04:50 EDT 2012

Hello!

I have defined a struct in some file (create.rkt) like this:

...
(provide create make-create)
(define-serializable-struct create (name key assigned-date due-date))
…

In client.rkt, given name, key, assigned-date, and due-date as well as an
out-port called out, I do:

(require "create.rkt")
...
(define some_var (make-create name key assigned-date due-date))
(write (serialize some_var) out)

In another file, server.rkt and with the in-port analogous to out, I do

(require "create.rkt")
...
(define request (deserialize (read in))

However, when my program gets to this point, it fails with the following
error:

dynamic-require: unknown module: '#%embedded:g1612:create

 === context ===
/usr/local/Cellar/plt-racket/5.2/lib/racket/collects/racket/private/serialize.rkt:601:8:
loop
/usr/local/Cellar/plt-racket/5.2/lib/racket/collects/racket/private/serialize.rkt:596:2:
deserialize
/Users/dlobraico/Sandbox/2012-cs151-staff/information-systems/server.rkt:29:0:
handle
/Users/dlobraico/Sandbox/2012-cs151-staff/information-systems/server.rkt:47:12


I am having trouble even beginning to debug this because it's not entirely
clear to me why dynamic-require wouldn't be able to find the create module
here and the error message is slightly cryptic to me. Any pointers or
guidance would be greatly appreciated!

Thanks,
Dominick
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20121004/881913c7/attachment-0001.html>

Posted on the users mailing list.