From: James Coglan Date: 2008-08-20T06:54:31+09:00 Subject: Re: Serializable Proc ------=_Part_44224_11639005.1219183080325 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 2008/8/19 Patrick Li > > You mean where the closure would point to the same variable after > > being reloaded? I'm not sure how that's going to work. > > Yes. ie. > a = 3 > p = lambda{a} > Marshal.dump(p, File.open("myProc.proc", "w") > > so that I can go > p = Marshal.load(File.open("myProc.proc", "r")) > p[] #should print 3 > > The 'connections' between variables should be saved. As well as the > values of the variables currently in the closure. I was hoping ruby2ruby would help, but I can't get it to run on my Windows box at present -- will try again on Ubuntu later. If anyone figures out how to do this I would be thrilled, as I'm trying to do a similar thing in JavaScript. Said language at least gives you a Function#toString method that gets you part-way there, but getting the values of variables if the function was created inside a closure is something I've not cracked yet. James Coglan http://blog.jcoglan.com http://github.com/jcoglan ------=_Part_44224_11639005.1219183080325--