[plt-scheme] object serialization?

From: Jefferson Provost (jp at cs.utexas.edu)
Date: Tue Nov 19 03:17:23 EST 2002

Is there an object/data serialization library of any kind for 
plt-scheme?  Basically, I want to be able to dump the state of an object 
  out to a file, and read it back in again.  In particular, I'd like to 
be able to do this without having to write a special procedure for every 
object class.

I've written something like this for Common Lisp, but it relies on 
CLOS's generic functions and an allegro-specific introspection function.

It uses write and read as the default serialize/deserialize.  Anything 
that can't be simply written and read needs special 
serialize/deserialize methods, which I've written for everything that's 
useful for me.  For objects, I've written a "serializable" parent class, 
which recursively serializes all the objects slots (fields), unless 
they're explicitly excluded by the child class.

It's not totally general:  I can't serialize closures.  Serializable 
objects can't have required instantiation parameters. And it clearly 
will have problems if objects share state, since the shared state will 
be serialized twice.  Still, it works for my needs (so far), and is very 
helpful, since my objects -- robot "brains" basically -- are fairly 
large, with state accumulated from many hours (or days) of operation.

Any clues how to do something like this in plt-scheme?


Posted on the users mailing list.