From: Paolo Nusco Perrotta Date: 2007-01-25T04:20:09+09:00 Subject: Re: Trickery in the ancestors chain Catch-all reply: On Jan 24, 7:03 pm, "Phrogz" wrote: > >But it works as documented. Why do you want to change it?I have two, different responses: > > 1) OK, you're right Yes, it's a feature - I found the C implementation in file class.c, lines 396 and following (for Ruby 1.8.5). Ruby skips the inclusion of M in D when D already includes M by way of an ancestor (or itself). This normally prevents me from adding the same module to the ancestors chain twice. But I can work around this by including the module in D first, and later in the ancestor. I see that most people think this is how it should work. I guess I'm easily surprised, but I wasn't expecting the order of inclusions into a hierarchy to make a difference. So, I wonder: why does Ruby go to the trouble of preventing this in the first place? If it does, shouldn't it do it all the time, not sometimes? If including a module twice is an error, shouldn't Ruby raise an exception? I don't have a strong opinion on this, but it feels strange.