From: "David A. Black" Date: 2005-05-08T00:57:36+09:00 Subject: Re: object reference handle (like perl's reference to scalar) Hi -- On Sat, 7 May 2005, Dave Burt wrote: > I don't think what I've done here is anything like that. The concept of a > reference here is just a wrapper or pointer, and it has to have a use. Sure, > it causes problems in C and Perl, and Ruby definitely offers more elegant > tools fo most of the problems that are solved in those languages with > pointers, but I'm coming from a Rubyist's perspective here, and all I'm > proposing is a new container, for a single object. > > And I think Austin's PDF::Writer example is one case where it's useful (that > is, passing an object by reference into a method so the method can replace > the object). It's a bit misleading to call it "passing by reference". In Ruby, all passing is by value. Many values happen to be references. If you have a Ref object, and pass it to a method, you are passing it by value-which-is-a-reference. That doesn't change, even if the object itself is of a class called Ref or Reference or Pointer, etc. I understand that when you then *do* something with that object, you are manipulating a second object, in a manner that emulates non-Ruby reference semantics. But still, as far as what's happening when you call the method with a Ref argument goes, it's still business as usual for Ruby. David -- David A. Black dblack@wobblini.net