From: William Djaja Tjokroaminata Date: 2002-08-01T02:39:29+09:00 Subject: Re: How to Emulate C/C++ Pointer/Reference in Ruby? Thanks for all the responses. For efficiency purposes (because the file is accessed so often), probably I prefer 2) rather than 3). Depending on the implementation, I guess, 1) will be somewhere between 2) and 3). However, this is only for the one specific example. I guess, then, indeed there is no way to emulate pointer in Ruby. I used Perl not for long before I switched to Ruby. If I am not mistaken, in Perl there is stuff called reference. Regards, Bill ======================================================================== > Some other options: > 1) Use a delegator. A SimpleDelegator can change the object it is > delegating to on-the-fly. The children get a reference to the > delegator instead of to the IO object you are using. > 2) Use the observer pattern. Whenever you change which file you are > accessing, mark your state as changed and notify your observers > that they need to refetch their references. > 3) Use ts's suggestion of always accessing the file object via an > accessor in the root object. > Paul