At 19:14 29/04/2004 +0900, you wrote: >"Jean-Hugues ROBERT" <jean_hugues_robert / yahoo.com> schrieb im Newsbeitrag >news:6.0.1.1.0.20040429071924.01cd1ef0 / pop.mail.yahoo.com... > > Hi, > > > > I am coining a Pointer class in Ruby. Kind of a C pointer, more > > like a C++ smart pointer actually. Should work for any lvalue. > >Care to share what usage you envision for this? > >Btw: this rather looks like a reference than a pointer. As far as I >understand, you create an alias for some variable (possibly a local var) >as a handle to modify it from outside the original scope. Is that >correct? > > robert Correct. But it should works for any lvalue not just variables. i.e. ref{"a_hash[3]"} for example. I initially named it a reference. But, references are usually automatically dereferenced (they are more transparent than pointers). I could no find a way to do this in Ruby. That is why I am using the []() accessor to get the referenced value. This is very similar to what you do in C with a pointer using * (content of). So, I eventually renamed the class Pointer. Now, I may be wrong about the difference between a pointer and a reference and I would be happy to change the code to something better. Yours, Jean-Hugues ------------------------------------------------------------------------- Web: http://hdl.handle.net/1030.37/1.1 Phone: +33 (0) 4 92 27 74 17