On 3/1/07, Ruby Admirer <ruby_admirer / yahoo.com> wrote:
> I'm just wondering if the behaviour of included modules is expected to change in Ruby 1.9.
>
Just to bring the discussion over to this thread.
The version of Ruby 1.9 sometime around last October changed this so that
including a module in a subclass which was already included in a
superclass would re-include it:
module M
end
class C
include M
end
class D < C
end
class E < C
include M
end
In Ruby 1.8 the inheritance chain for E would be
[E, D, M, C, Object, Kernel]
and in the old 1.9 it would be:
[E, M, D, M, C, Object, Kernel, BasicObject]
as of today's build 1.9 gives
[E, D, M, C, Object, Kernel, BasicObject]
Note that this will have different semantics in the case that an
intervening class like D re-defines a method inherited from M, with
the 1.8 semantics, E can't get the method from M by reincluding M.
I'm not sure why this changed back or whether it will stay that way.
--
Rick DeNatale
My blog on Ruby
http://talklikeaduck.denhaven2.com/