From: Eric Hodel Date: 2005-08-17T05:27:31+09:00 Subject: Re: drb client-side proxies On 16 Aug 2005, at 09:15, Mark Volkmann wrote: > On 8/15/05, Eric Hodel wrote: > >> On 14 Aug 2005, at 12:40, Mark Volkmann wrote: >> >> >>> The source file lib\ruby\1.8\drb\drb.rb defines the class >>> DRbObject. I >>> don't understand the initialize method. Why would I ever want to >>> pass >>> something other than nil for the first parameter? The comment above >>> the initialize method says that is used to create a proxy/stub for a >>> local object. Why would I want to do that? >>> >>> The typical way to use this is >>> >>> proxy = DRbObject.new(nil, url) >> >> You can pass DRbObjects across the wire, so you could wrap a local >> object and pass the DRbObject across the wire to the other side. If >> you look around in drb.rb you'll see several places where it is used. > > Are you saying that this is a way to force a pass by reference? > I can also do that with DRbUndumped. > Are these blocks of code equivalent in what they accomplish? > > obj.extend DRbUndumped > remote_obj.some_method(obj) > > remote_obj.some_method(DRbObject.new(obj)) Yes. DRbUndumped overrides _dump which causes a DRbObject to be created wrapping obj. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04