[REBOL] Re: Rebol pickling recipes ?
From: greggirwin:mindspring at: 3-Oct-2002 21:49
Hi Jason,
<< After a few days with Python I am wondering how to 'pickle' Rebol
objects? >>
I guess that depends on exactly what your needs are. With REBOL, you have a
number of options. You can MOLD objects and then write them out, you can
write out just the spec block for them, you can serialize things out as
blocks - or any data really - even if they aren't objects. This is one of
those things that is so simple in REBOL, it makes you forget how hard it is
in other languages (i.e. that they have to provide serialization mechanisms
which were probably a lot of work for them to write :). The great benefit of
code/data duality shines bright.
SAVE and MOLD both have an /ALL refinement now which creates a "true"
serialized format.
>> o: make object! [a: 1 b: none c: [zippy--pinhead--com] d: false]
>> mold o
== {
make object! [
a: 1
b: none
c: [zippy--pinhead--com]
d: false
]}
>> mold/all o
== {
#[object! [
a: 1
b: #[none]
c: #[email! "[zippy--pinhead--com]"]
d: #[false]
]]}
>> o2: do load mold o
>> probe o2
make object! [
a: 1
b: none
c: [zippy--pinhead--com]
d: false
]
>> o2: load mold/all o
>> probe o2
make object! [
a: 1
b: none
c: [zippy--pinhead--com]
d: false
]
--Gregg