But a further question is: how fundamental is the inheritance hierarchy
to designing programs in Ruby, given the non-kind_of? underpinnings of
Ruby objects (i.e., their dynanism and “in-the-moment” behavior)?
···
----- Original Message -----
From: dblack@candle.superlink.net
I’m not sure I understand what you mean. kind_of?' determines what methods an object has, even if those methods are dynamically added, or singleton methods, or whatever. Without
kind_of?’ (meaning the inheritance heirarchy
it represents), Ruby objects would become C structures!
In that quote, matz seemed to be against over-using inheritance. And I
think that’s similar to my original point: don’t subclass from a class
(base class or not) unless you want to use the subclass in place of the
class. Don’t inherit from Array unless you are making a new kind_of? Array;
a class where you will want to use every method Array has, and (perhaps)
then some.
Removing methods from a subclass is generally a sign that it should not be a
subclass, IMHO. (That’s one of the reasons why I think Method should be a
subclass of UnboundMethod, and not the other way around.)
Chris