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

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

Yup, it even says it in the documentation under the prefab section.  I just
didn't make it far enough down the page.

Thanks.

On Tue, Dec 13, 2011 at 10:12 PM, Vincent St-Amour <stamourv at ccs.neu.edu>wrote:

> Structs are generative, so this won't work.
>
> Prefab structs are probably what you want here.
>
> Vincent
>
>
> At Tue, 13 Dec 2011 22:05:40 -0600,
> Todd Bittner wrote:
> >
> > [1  <multipart/alternative (7bit)>]
> > [1.1  <text/plain; ISO-8859-1 (7bit)>]
> > 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.
> > [1.2  <text/html; ISO-8859-1 (quoted-printable)>]
> >
> > [2  <text/plain; us-ascii (7bit)>]
> > _________________________________________________
> >   For list-related administrative tasks:
> >   http://lists.racket-lang.org/listinfo/users
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20111213/b46421b1/attachment.html>

Posted on the users mailing list.