[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Re: Ruby 1.9 - Change of included modules behaviour ??

Rick DeNatale

3/1/2007 5:03:00 PM

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.denh...