From: ptkwt@...1.aracnet.com (Phil Tomson) Date: 2002-01-08T08:19:05+09:00 Subject: Globals and passed objects (dRuby) This is related to an application of the Ruby Distributor. I'm distributing TestCase objects which have a 'run' method to clients. On the clientside there is one global, $RESULTS_DIR, which is the path to a directory where results are stored. Now, the server (Distributor) instantiates a TestCase object which is then sent to a dRuby object on the Client machine. The Client then invokes the TestCase objects 'run' method which in turn creates several other objects on the client side. One of the objects relies on $RESULTS_DIR to figure out where to store it's results. But, $RESULTS_DIR in this context is nil even though we're running on the client and the client program initially set up $RESULTS_DIR. My theory is that as soon as we run the TestCase object's 'run' method on the client that now TestCase doesn't know anything about the client's globals since the TestCase object was created on the server machine. Does this make sense? Here's some very chopped down code that I hope illustrates the problem: Server side: tc = TestCase.new() distributor.send(tc) #this sends the testcase to the client machine Client side: $RESULTS_DIR="/home/results_dir" .... #after receiveing the testcase, tc: tc.run #later, now somewhere in tc's run method: File.copy(results, $RESULTS_DIR) #but the copy doesn't succeed because $RESULTS_DIR is nil here Why wouldn't $RESULTS_DIR be visible in the context of the tc object's run method? Phil