On Jun 11, 2005, at 11:50, gabriele renzi wrote: > Renzo Orsini ha scritto: > >> Hi, >> I know there are several ways of saving ruby objects on files, >> but there is a simple way of saving ALL the >> state of a Ruby program execution (or an irb work session) and >> then reload it in another execution (or session)? >> In this way I could use Ruby as a sort of Persistent Programming >> Language (or Object Database Language). >> > > > well, using irb you have an hackish solution: you could do an eval > of the history. > Look here[1] for some info on how you could get a persistent > history beetween irb sessions. The next part is just re-evaluating > it on startup. This could be of some help, in effect, but only for simple cases. > Saving the state of the program would be hard since you can't > serialize closures, singletons and continuations, I would be happy just to save classes, objects and global variables that I have defined, or a subset of them, but it seems to me that with Marshal.dump I cannot even save a class in irb: irb(main):009:0> class C irb(main):010:1> def m irb(main):011:2> 3 irb(main):012:2> end irb(main):013:1> end => nil irb(main):014:0> Marshal.dump(C, File.new('f','w+')) => #<File:f> then I quit, reload irb and irb(main):001:0> Marshal.load(File.new('f')) ArgumentError: undefined class/module C from (irb):1:in `load' from (irb):1 (I don't undestand the meaning of this message..., and also I read that a class is nothing more than an object... :-) > Oh, and welcome to ruby :) Thanks! Renzo Orsini