From: gabriele renzi Date: 2004-03-10T00:49:40+09:00 Subject: Re: when a required module redefine another module => problem il Tue, 09 Mar 2004 16:07:17 +0100, shasckaw ha scritto:: >The fact is that it would be more adequate to have Enumerable modified >in SomeModule only. This case is simple, but we can imagine more vicious >sample codes, with some method redefined => it will affect the whole >program! This is a problem, isn't it? > >What do you think about this? > this is a problem that I have'nt faced yet, but people talk about it from time to time. Matz said in the latest ruby conf that ruby2 could have a construct like: namespace 'foo' do do bad stuff end do other stuff but I believ that could be quite bad in performance. Talking about your problem: you may add private :to_set to OutModule, or you could just lock Enumerable: Enumerable.freeze. require 'set' rescue nil and add to_set by yourself: class InModule def to_set Set.new(self) end end Btw I agree that a require should affect the actual scope not the toplevel one. (bad idea inside: change the semantic of class K end to be implicitly class K < ::K end to avoid namespace clashes and still get the feeling of singletons ;P )