[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Serializing Ruby code

Victor 'Zverok' Shepelev

12/3/2006 3:06:00 AM

Hi all.

A bit of philosophy.

We have Marshal[1] to serializing Ruby's objects (and also YAML and so on).
AFAIK, Rails community even uses objects serialization for program's state
saving.
But, existing marshalling/serialization can serialize only data, not plain
code; this fact is restricting for their applications. For example,
Smalltalk-style "image" (entire program state, which can be loaded and
continued) is impossible.

But! We have a method for translating code-to-data - ParseTree[2], and we
even have method to translate back data-to-code (though a bit roundabout) -
ruby2ruby[3].

Had somebody thought about gathering all this to create full solution for
entire running program "saving" and "loading"? (Or, may be, somebody already
done this and I'm missing?)

It can be really cool. And it seems completely possible.

V.

1. http://www.ruby-doc.org/core/classes/Ma...
2. http://rubyforge.org/projects...
3. http://seattlerb.rubyforge.org/...


5 Answers

Chris Pearl

12/3/2006 3:16:00 AM

0

If I understand your question correctly, what you're looking for is
serializable continuations.

I've checked this a while back, and the current stable Ruby branch
(1.8.x) does not have those, though it supports continuations
themselves. There are no plans to add serialization for continuations
in this branch, afaik. Perhaps it would be added in the future Ruby
implementations (at least in some of those ;-)) but here's where the
implementation developers chime in...

-Chris

On 12/3/06, Victor Zverok Shepelev <vshepelev@imho.com.ua> wrote:
> Hi all.
>
> A bit of philosophy.
>
> We have Marshal[1] to serializing Ruby's objects (and also YAML and so on).
> AFAIK, Rails community even uses objects serialization for program's state
> saving.
> But, existing marshalling/serialization can serialize only data, not plain
> code; this fact is restricting for their applications. For example,
> Smalltalk-style "image" (entire program state, which can be loaded and
> continued) is impossible.
>
> But! We have a method for translating code-to-data - ParseTree[2], and we
> even have method to translate back data-to-code (though a bit roundabout) -
> ruby2ruby[3].
>
> Had somebody thought about gathering all this to create full solution for
> entire running program "saving" and "loading"? (Or, may be, somebody already
> done this and I'm missing?)
>
> It can be really cool. And it seems completely possible.
>
> V.
>
> 1. http://www.ruby-doc.org/core/classes/Ma...
> 2. http://rubyforge.org/projects...
> 3. http://seattlerb.rubyforge.org/...
>
>
>

Eric Hodel

12/3/2006 4:01:00 AM

0

On Dec 2, 2006, at 19:06 , Victor Zverok Shepelev wrote:

> A bit of philosophy.
>
> We have Marshal[1] to serializing Ruby's objects (and also YAML and
> so on).
> AFAIK, Rails community even uses objects serialization for
> program's state
> saving.
> But, existing marshalling/serialization can serialize only data,
> not plain
> code; this fact is restricting for their applications. For example,
> Smalltalk-style "image" (entire program state, which can be loaded and
> continued) is impossible.
>
> But! We have a method for translating code-to-data - ParseTree[2],
> and we
> even have method to translate back data-to-code (though a bit
> roundabout) -
> ruby2ruby[3].
>
> Had somebody thought about gathering all this to create full
> solution for
> entire running program "saving" and "loading"? (Or, may be,
> somebody already
> done this and I'm missing?)

You'd need more than that to get a full image to work (like recording
the ObjectSpace, the symbol table, globals, ...)

Also, ParseTree doesn't capture the closure so you can't copy the
full state of the interpreter:

$ cat closure.rb
def make_proc
x = 1
proc do |y| y + x end
end

p = make_proc

puts p.call(2)

require 'rubygems'
require 'ruby2ruby'

ruby = p.to_ruby

puts ruby

q = eval ruby

puts q.call(2)

$ ruby closure.rb
3
proc { |y|
(y + x)
}
(eval):2: undefined local variable or method `x' for main:Object
(NameError)
from closure.rb:19:in `call'
from closure.rb:19

--
Eric Hodel - drbrain@segment7.net - http://blog.se...

I LIT YOUR GEM ON FIRE!


Stormy

3/7/2013 3:23:00 PM

0

LOL Turin, paul elam (aka giant attitude) is still obsessing on you.
That's what happens when a molester harms one of his patients an' you
say 'hey! that molester harmed one of his patients!" :)

Marxette

On 03/07/2013 09:54 AM, Giant Attitude wrote:
> On Thu, 07 Mar 2013 08:55:40 -0500, Masculist
> <littleguysfirst@gmail.com> wrote:
>
>> That's how many I turned in. Flo's been stealing a bunch from work and
>> giving them to me. My sucker friend is sending me another $200, my fake
>> back problem stipend rolls in, a few punks dealing on the street for me,
>> and a few of my other scams means we're doing ok.
>>
>> Flo thinks I should put up another Paypal link for my AUM fund so that
>> we can get a big TV. <G> See, there are scumbag Marxists and then there
>> are smart Marxists.
>>
>> Tom
>
>
> Sorry to hear that, Turd.
>
> Can't "Stormy" or "Marxette" help out until you get back on your feet?
>
> "Stormy" hasn't shown up in a while. Did he/she desert you once you
> ran short of money? I hate it when a sockpuppet proves unfaithful.
>

MCP

3/7/2013 3:37:00 PM

0

On 07/03/2013 15:22, Marxette Marx wrote:
> LOL Turin, paul elam (aka giant attitude) is still obsessing on you.
> That's what happens when a molester harms one of his patients an' you
> say 'hey! that molester harmed one of his patients!" :)
>
> Marxette

You are one sicko tosser,Turd.....i see you are still in love with that
Paul Elam guy,are you his bum buddy? :-)

MCP

MCP

3/10/2013 12:23:00 AM

0

On 03/09/2013 12:54 AM, MCP wrote:
> TurinTurambar.1@gmail.com

paulbiz57@yahoo.com