From: Mathieu Bouchard Date: 2001-10-04T08:05:45+09:00 Subject: [ruby-talk:22035] Re: Marshal won't dump a Proc On Thu, 4 Oct 2001, Paul Brannan wrote: > How about the following? The only major disadvantage is that it will be a > little bit slower than using a real Proc: I wrote this program with Guy Hurst on April 6th. You say that a proc should keep its source by prepending a % sign just before the opening-brace. class Proc attr_accessor :source class << self def _load(aString) foo=eval(aString) foo.source=aString foo end end def _dump(aDepth) source or raise "sourceless Proc cannot be dumped" end end module Kernel alias :old_proc :proc def Kernel.proc(string=nil,&b) if string and b then raise "bad argument, dude" end if string then Proc._load("proc{#{string}}") else old_proc(&b) end end def proc(string=nil,&b); Kernel.proc(string,&b); end end ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju