tags:

views:

59

answers:

3

http://spoon.net let's you execute desktop application by downloading them from the web. When you quit it restores the system.

On http://askpoweruser.com I'd like to do the same thing. My idea would be to persist the whole system hierarchy on disk and then restore it at the end of execution.

Is a single line of code would be enough (seems like too easy for such complex feature that's why I doubt :)):

save %system.txt system

what is serialize refinement ? would it be usefull in that case ?

to restore system would I then just do

load %system.txt
+1  A: 

You can't currently save the entire Rebol image like this. You can serialize Rebol values by using 'mold/all and save values by using 'save. But AFAIK the serialization doesn't properly save functions inside objects.

Graham Chiu
oh that's a pity :(
Rebol Tutorial
still can I do it if I can create a function to also save the functions ?
Rebol Tutorial
endo64
I can't find an example now ... but I did have a problem with serializing and restoring some Rebol objects last year, and I was told it was a Rebol bug.
Graham Chiu
@endo64 @grahm can you post your code that works and that doesn't ?
Rebol Tutorial
I made an example with some nested objects, functions which has local block variables etc. and it worked all of them, I'll write it as an answer for formatting issues.
endo64
There are 2 major problem about this: one is port states, network ports etc. cannot be saved and loaded easily. and the second is circular references. For ex. you cannot save try to save/all and open the file you will see "#[object! [b: #[object! [...]]]" it gives error when you load it.
endo64
+1  A: 

You could use something like CryoPID:

http://cryopid.berlios.de/

That would work at the process level, and you could use it for things besides Rebol. But it would be OS-specific.

Hostile Fork
I don't need to go as far but why not thanks for this amazing findings I didn't know it even exists :)
Rebol Tutorial
+1  A: 

here is my object:

>> o: context [b: "b" f: does [do make function! [] [print ["a"]]] oo: context [a: 1]]
>> ?? o
== o: make object! [
    b: "b"
    f: func [][do make function! [] [print ["a"]]]
    oo: make object! [
        a: 1
    ]
]

change something in function f:

>> o/oo/a: 2
>> append second last second first next next next third :o "b"
>> o/f
== a b
>> save/all %t.r :o
>> p: load %t.r
>> ?? p
== p: make object! [
    b: "b"
    f: func [][do make function! [] [print ["a" "b"]]] ;<----
    oo: make object! [
        a: 2              ;<------
    ]
]
>> p/f
== a b ;<----

it looks everything is ok. But of course this is just a single test.

endo64