Hi,

Is there any easy way to emulate C pointer or C++ reference in Ruby?

Basically, the problem is something like this.  I have a root object,
and it contains an instance variable that refers to, say, a file. 
When the root object is created, it opens the file.  Then the root
object creates many other child objects, passing the value of the file
variable in the process.  Any child object will write to the same
file.

Now, in the middle of execution, the root object may close the file,
and some other program may access the file.  When the root object
reopens the file, all the file variables in the child objects are no
longer valid.  Therefore, I think it will be nice if the we can have
some "reference" or "pointer", so that the child objects' file
variables always point to the root object file variable.

The only solution that I can think of for now is for the root object
to remember all the child objects, and to modify all the child
objects' file variables whenever the root object file variable
changes.  However, to me this is more like design pattern than a
language feature.  (I read somewhere that in general the issue with
programming languages is not whether something is possible, but rather
whether the thing is facilitated.)

Regards,

Bill