drb pass by reference

M

Mark Volkmann

I've been reading about DRb from several sources including the
documentation at the beginning of drb.rb. I'm troubled by the
mechanism for passing objects by reference instead of by value. From
what I've read you have to add "include DRb::DRbUndumped" to the class
of the objects being passed. What if I want to pass some objects of
that type by reference and others by value?

--=20
R. Mark Volkmann
Partner, Object Computing, Inc.
 
B

Brian Candler

I've been reading about DRb from several sources including the
documentation at the beginning of drb.rb. I'm troubled by the
mechanism for passing objects by reference instead of by value. From
what I've read you have to add "include DRb::DRbUndumped" to the class
of the objects being passed. What if I want to pass some objects of
that type by reference and others by value?

See if the explanation here makes any sense:
http://www.rubygarden.org/ruby?DrbTutorial

And then if you don't know about singleton classes, read here:
http://www.rubygarden.org/ruby?SingletonTutorial

Then you should be able to see that

a = Foo.new
b = Foo.new
a.extend Drb::DRbUndumped

will result in 'a' being passed by reference, and 'b' by value.

HTH,

Brian.
 
E

Eric Hodel

I've been reading about DRb from several sources including the
documentation at the beginning of drb.rb. I'm troubled by the
mechanism for passing objects by reference instead of by value. From
what I've read you have to add "include DRb::DRbUndumped" to the class
of the objects being passed. What if I want to pass some objects of
that type by reference and others by value?

Don't include (or extend) DRb::DRbUndumped.

Remember when you pass by value, both sides must know the class
definition for the object being passed.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,780
Messages
2,569,610
Members
45,255
Latest member
TopCryptoTwitterChannels

Latest Threads

Top