On Fri, Mar 02, 2007 at 08:10:10AM +0900, james.d.masters / gmail.com wrote:
> > Go back and look at my earlier post...
> 
> OK, I did... and I also ran the code that you provided in the second
> example.  I really do understand the concept of class instance
> variables.  But I'm trying to show how they can be preset and have the
> preset values inherited.

Maybe this is where the confusion arises. Here you're talking about
inheritance of *values*, which implies the value from class A is *copied* to
class B. The trouble with that approach is, when exactly do you copy the
values? When class B is first created? But that assumes that class A has
already set its instance variable. If it hasn't, then there's nothing for
class B to copy.

That's why my suggestion was to set the value in the class's own instance
variable space only, and not copy it, but at the point when you *read* the
value, if you don't have it in your own instance variable space then walk
upwards.

However, I'm really not sure what problem we're trying to solve - i.e. in
what circumstances this behaviour would actually be useful. If class A and
class B both set their own values, then they behave just like class instance
variables do now. And if class B wants to 'share' a value with class A, then
it would have to ask class A explicitly to set it:

  class B
    ...
    A.per_class = whatever
    ...
  end

in which case, again, this is just a class instance variable in A, and it
could read it using the same syntax:

  class B
    ...
    foo = A.per_class
    ...
  end

I don't see where you'd need the magic that B.per_class returns the same as
A.per_class, except for the case where B.per_class has set its own value to
override it.

B.