From: Robert Klemme Date: 2004-03-10T21:39:38+09:00 Subject: Re: when a required module redefine another module => problem "shasckaw" schrieb im Newsbeitrag news:404ef6ac$0$780$ba620e4c@news.skynet.be... > Robert Klemme wrote: > > I think this is not limited to modules but to *all* situations in Ruby > > where you can redefine existing things (classes, methods, instance methods > > etc.) and where this is done in different places that don't know anything > > about each other. But since this feature is mentioned as one of the > > strengths of Ruby ("flexibility") most of the time, I'd say apparently > > it's not a problem. After all, most of us around here are aware of this > > and it doesn't stop us from using Ruby, does it? :-) > Well, I must tell I wasn't aware of this until recently. But that's > true, I won't stop using ruby for that. But there is a thing that seems > strange to me with that fact. It's only strange for you because you have certain expectations that don't match require's behavior. Maybe you're coming from a C / C++ background and expect require to behave similar to #include. > If extend can mix in a module in the class of an instance and be > available only for that instance, why requiring wouldn't be local to the > module where require is called? Or at least only its class > redefinitions? (same remark for include) Because require and extend are two fundamentally different things: require is agnostic of scopes and other programming language artefacts. It merely loads (and possibly interprets) a file if that hasn't been loaded already. So it's logical that the required file is always evaluated from main scope. Apart from that, since require can also load shared libraries, dealing with scopes here would be even more difficult. Regards robert