Dan Janowski
11/29/2004 10:16:00 PM
What I am looking for is very similar to a clone. However, instead of
the instance variables referring to the same objects, the variables use
the same reference storage. This way, 'b' which is a friend of 'a' can
change a value of a shared variable and 'a' has the same change. 'b'
can be extended via singleton methods that do not change the 'a'
instance definition.
I can get close with clone as long as I read-only or change! the shared
instances, but the replacement of a reference in one has no effect on
the other.
I know I can use instance_eval, but I was hoping for something like
'clone' in its directness.
Is there any consideration of this? Is it possible to do with Ruby's
internal constructs? I think that an anonymous subclass is created when
singleton methods are added, but can one instance be directly related
to another instance with the base instance providing its variables as
well?
Dan