开发者

Programming a sandbox environment in rebol a bit like spoon.net

开发者 https://www.devze.com 2023-01-11 08:41 出处:网络
http://spoon.net let\'s you execute desktop application by downloading them from the web. When you quit it restores the system.

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 f开发者_JS百科or 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


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消