Binary storage

Lex Spoon lex at cc.gatech.edu
Wed May 29 19:00:06 UTC 2002


Martin Drautzburg <martin.drautzburg at web.de> wrote:
> 
> Is there a way in squeak to save and restore objects to/from disk as
> in stx ? 
> 
> The #storeOn: method does not preserve object identity and does not
> handle circular references or does it ?

There are a number of ways, depending on your goals.  For example:

	storeOn: (as you discovered)
	DataStream
	ReferenceStream (can handle cycles)
	SmartReferenceStream  (tries to be intelligent about things like World
and Smalltalk, and includes the code for uniclasses)
	ImageSegment (already mentioned.  Primarily useful for large objects
like projects.  Not so great for small objects like network packets.)


It would be excellent if someone were to write a longer summary of all
these mechanisms, and post it on the Swiki.  (If I'm overlooking such an
essay that already exists, then could someone post it somewhere more
prominent in the Documentation area of the swiki?)


Lex


PS -- your next question might be about database support, so that you
can manage your exported objects.  See:

	http://minnow.cc.gatech.edu/squeak/512


PPS -- Most of the above mechanisms rely on specific versions of classes
in the image.  Even SmartRefStream, which can deal with class changes,
cannot *easily* do so.  Thus, you may find that changes to your code
will invalidate all objects you have exported in the past.  You may wish
to consider designing a file format by hand instead of just dumping
objects.  That way you won't get any accidental format changes, and can
manage the process explicitly.  It's a pain, but it's probably better if
you want long-lasting data.

I wonder what schemes people have devised for dealing with this problem?
 It must be a problem for databases, for example.  Perhaps there are
schemes that could be stolen and used in Squeak.



More information about the Squeak-dev mailing list