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 ?
Hello,
The #storeOn: method does not preserve object identity and does not handle circular references or does it ?
Perhaps the best way is to use ImageSegment. You can find some on the minnow Swiki.
Anyway, actually it works only for squeak 3.2, once I will finish my work about integrating ImageSegment with modules, it will work with squeak 3.3.
Alexandre
Martin Drautzburg martin.drautzburg@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.
squeak-dev@lists.squeakfoundation.org