From: HarryO Date: 2001-10-04T05:46:08+09:00 Subject: [ruby-talk:22030] Re: Marshal won't dump a Proc In article <1002126975.600438.16806.nullmailer@ev.netlab.jp>, "Yukihiro Matsumoto" wrote: > Procs, Bindings and Continuations contain references to C stack > information which is not portable. Methods have references to C > function. All of above information is not portable. Thanks to matz and Will for those explanations. The Proc I wanted to dump/restore is a block that's provided when an instance of my class is created. It specifies how to get the nth element of a sequence and hence can be pretty much anything. Hence, asking the user to write it as a string that's going to be eval-ed would make using my class a little messy. I've provided a mechanism whereby the user can ask for the current set of values to be saved between sessions. This is useful for sequences where the calculation time is significant, eg generating prime numbers. I then thought it would be nice to be able to store the Proc that defined how to get the next element, so then you could load one of these sequences without having to have the original code. Ie, the dump file would carry all the information required to continue from where the last program that used that sequence left off. I can see now that storing a Proc would be much more complex than I'd originally thought. While the block of code I want to save is generally going to be self-contained, I guess there's no way for the serialisation of a Proc object to know that. In any case, I guess that even the simplest piece of code, eg "{ |i| i }", uses Object and serialising that could presumably be quite complex, especially since someone could have used the dynamic features of ruby to modify Object by adding or changing methods. Nothing's ever as simple as it seems, is it :-) ?? What I might be able to do is provide two means of constructing the object, one by attaching a block and the other by passing a string that's eval-ed into a Proc for run-time use and dumped/restored for persistence. Thanks again for the lucid explanations.