Saving objects with Hackney

Russell Allen mail at russell-allen.com
Sun Jan 2 09:32:23 UTC 2011


All the talk about object saving etc inspired me to throw together a rough sketch of a framework for object saving as a exercise in building stuff in Self. The code builds upon the transporter's facilities but ignores modules.

All it does is take a object root, map out the bounds of the object cluster using a fitness test, then write out the set of objects on the file in a pleasing indented manner. It more or less handles internal loops; but a nice mechanism for that depends on moving the parser from the VM into Self. It has a hardcoded limit of 1000 objects to iterate over, just to make development easier by preventing accidentally iterating over the entire image.

The current fitness test is simply whether (a) the sub-object has a creatorPath and (b) whether it is a worldMorph. Playing with this is a good illustration of Dave's point that the tricky question is where to stop!

This is a rough outline of a framework for testing stuff (in particular there aren't any tests and the code is ugly :) - it probably isn't particularly useful.

Things I missed while writing this: a streams library, a unit testing framework, a modifiable Self parser 

If you take a clean snapshot and put the attached hackney.self file in the same directory, you can load it by:

bootstrap read: 'hackney' From: ''

and then save objects as:

transporter hackney save: myObject As: fileName

and load by getting the results of:

transporter hackney read: fileName

Have fun, Russell

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/x-ygp-stripped
Size: 149 bytes
Desc: not available
URL: <http://lists.selflanguage.org/pipermail/self-interest/attachments/20110102/4a4a6ddf/attachment.bin>


More information about the Self-interest mailing list