From: Nat Pryce Date: 2001-08-11T23:35:19+09:00 Subject: [ruby-talk:19533] Re: order and freedom in Ruby (was: Re: Re: the wayclass variables work) ----- Original Message ----- From: "David Alan Black" > On Sat, 11 Aug 2001, Chris Uzdavinis wrote: > > David Alan Black writes: > > Given a class, there is no guarnatee that any objects instantiated > > from it still share its interface at all. It's wishful thinking to > > assume two objects with the same "base class" have anything in common > > whatsoever, aside from that base class. > ... > > Question: Does inheritance honestly have any significant meaning in > > Ruby? It depends what you mean by "significant meaning"... :-) Inheritance has no relationship to type in Ruby (or Smalltalk or other dynamically typed OO languages). Type is defined by, and only by, the messages that an object understands at any given time. Inheritance is merely a convenience mechanism for reusing some or all of an implementation defined by another class. Inherited implementation can affect the type of objects instantiated from the derived class, but that can be overridden at any time. In Ruby, instead of defining classes or interfaces, you define protocols that objects should speak, and define those protocols outside the language. You can then define useful classes or modules that implement those protocols, but a programmer can just as easily write the protocol from scratch. An simple example of this kind of protocol is the relationship between the methods hash and eql? or the Enumerable mixin requiring the existence of the each method. Cheers, Nat.