In article <Pine.GSO.4.21.0112061022210.14067-100000 / godzilla.ce.chalmers.se>, Robert Feldt <feldt / ce.chalmers.se> 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