2006-08-31
Object Serialization with Factor
As Slava noted in his weblog, I've tidied up a previous serialization library to get it working with current Factor versions in the hopes of using it to get distributed concurrency working.
The serialisation supports most Factor types and is extensible by adding methods to generic functions. You can even serialize quotations containing words, and so long as those words exist in the target system, the deserialization will link them correctly and the quotation is callable. Actual code doesn't serialize at this stage though.
An example of usage:
"serialize" require
USE: serialize
[
[ "Hello World!" serialize ] with-serialized
] string-out
=> ...serialized format as a string...
[
[ deserialize ] with-serialized
] string-in
=> "Hello World!"
The 'string-out' and 'string-in' shown above are standard words to direct all output to go to and from strings respectively. You can also serialize to files and deserialize them on any other Factor system.