Florian Gross said:
> There's another small, but annoying problem with the proxy-approach:
> There are operations which can't be forwarded. I can only think of the
> truth value of an Object right now.

Comparisons are problematic because the first line of a comparison is
often "Are you the same class as me?".  Proxies arent't the right class so
the comparisons fail.

Actually, rather than a become or class= method, I would be interested in
a swap_identitys method.  For example, to make a proxy object real ...

  def make_real
    obj = read_real_object_from_the_database
    swap_identities(self, obj)
  end

When identities are swapped, every reference in the system to the first
object will magically become a reference to the second object, and
vice-versa.

There are no semantic problems with an object suddenly changing classes
and finding inappropriate member variables.  They just switch identities. 
This would be perfect for the proxy problem.

Although it solves semantic problems of become, I doubt it would still fly
with Ruby as it is today.  All objects would have to occupy the same
amount of memory for this to work (amoung other constraints).  I don't
think that's true of many of the built in classes.

-- 
-- Jim Weirich     jim / weirichhouse.org    http://onestepback.org
-----------------------------------------------------------------
"Beware of bugs in the above code; I have only proved it correct,
not tried it." -- Donald Knuth (in a memo to Peter van Emde Boas)