> > The original intent was to have a way to modify these
> > references that variables contain.  This provides a general
> way
> > of doing this.
> 
> Doesn't assignment do that?

Of course.  But the code doing this assignment has to know the
name of the variable and the binding(scope) it is in.  This
class encapsulates this information and gives get/set methods
to this variable (or thingy).

To not confuse this with "object reference" (which is many
times interchangeable with "object"), you could think of this
thing as a variable/attribute/member/element/thingy reference. 
Or even a reference to "object reference".  It also corresponds
directly with the phrase "pass by reference".  And it maps to
what references/pointers are in other languages.

> > A side effect is that you can do a lot more
> > though - all you need is a way to get and set the thing you
> > want to access.
> >
> > x = ref{:a} # allows you to get/set the reference that :a
> has
> >
> > x[]         # get the object that :a has
> > x[]=...     # set the object reference that :a has
> >
> > Here is another example (pass by reference):
> >
> > def swap(a,b)
> >    tmp = a[]
> >    a[] = b[]
> >    b[] = tmp
> > end
> >
> > swap(ref{:x},ref{:y}) # swap the object references in x and
> y
> >
> > See how useful this thing is?
> 
> I haven't seen any cases where I'd have wanted to have it,
> but I think
> experimentation of this kind is always interesting, even if
> not
> everyone has a direct use for it.

You can always find another way to do this.  This just provides
something else in our bag of Ruby tricks.  I think it is a nice
generally useful interface.




		
__________________________________ 
Do you Yahoo!? 
Make Yahoo! your home page 
http://www.yahoo.com/r/hs