From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2001-12-06T18:52:45+09:00 Subject: [ruby-talk:27664] Re: Sending a Proc to a remote dRuby object In article , Robert Feldt wrote: >On Thu, 6 Dec 2001, Phil Tomson wrote: > >> Is it even possible to pass a Proc to a remote dRuby object like this? >> >This is a "classic" q so if its not in the FAQ we should probably move it >there. Procs and Threads (and some other type of objects) cannot be >marshaled so dRuby will have problems... ;-) Maybe we should list which >classes are affected in the FAQ? This is what I thought, but why does this example work: #----remote object ------------ require "drb/drb" primary = DRb::DRbServer.new("druby://localhost:5555", [1,2,3,4,5]) primary.thread.join #----local-------- require "drb/drb" primary = DRb::DRbServer.new ts = DRb::DRbObject.new(nil, ARGV.shift) #try sending a proc: ts.each { |i| puts i } #prints, on local machine: 1 2 3 4 5 (I suppose the answer has soemthing to do with the proc executing on the local machine.) > >It has been discussed a lot and I think Matju (and someone more, >Chad?) proposed the nicest solution: add a source_code attribute to Proc >(or subclass) and redefine proc/lambda so that it sets the attribute if >given a string. Then add marshaling and the proper init and you're >set. Of course, it would be nice if future Ruby's could marshal all >objects but there are real problems with doing this for Procs and Threads >so maybe not. Yes, I would imagine it's a big problem >The nice thing about the solution above is that when using >this feature all you have to do is add a '%': > >proc %{|x| x*x} > That would be nice... Phil