[racket] Reading in data structures from files (specifically structs)

From: Todd Bittner (toddbittner at gmail.com)
Date: Tue Dec 13 23:05:40 EST 2011

I'm trying to do something like the following:

I create a struct, say (struct foo (bar baz) #:transparent), where bar is a
string and baz is an integer, and then write - using write, not display -
several instances of the struct to a file.  When I inspect the file, it
looks something like this:

#(struct:foo "string1" 1)
#(struct:foo "string2" 2)

When I read this back in to my program, I get an s-exp back that is
'#(struct:foo "string1" 1).  When I eval it, it's still '#(struct:foo
"string1" 1), and calling (foo?) on it returns #f.  Is there someway that I
can reconstitute this back into a foo struct?

Thanks.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111213/2ff32e10/attachment.html>

Posted on the users mailing list.