From: itsme213 Date: 2005-01-26T02:11:02+09:00 Subject: Re: top-level object? top-level methods? "Yukihiro Matsumoto" wrote in message > Hi, > > In message "Re: top-level object? top-level methods?" > on Wed, 26 Jan 2005 00:07:19 +0900, Pit Capitain writes: > > |I like this proposal. Would there be any drawbacks? > > 1. Compatibility. It would break a lot of code, which assume > top-level def can be seen from everywhere. A compatibility mode perhaps :-) class Object def method_missing sym, *args, &block if Main.respond_to? sym Main.send sym, *args, &block else normal_method_missing_stuff end end > 2. Mindset. I feel above assumption is natural. With the option of using modules and includes, I am not sure the namespace pollution is worth it. I do fully agree with one of the original goals of making procedural programmers quite at home, and don't think this approach would sacrifice that goal. I find myself throwing in top-level methods when in a rush, when it is convenient, I don't need multiple instances, etc. But I don't think I ever throw them in with the _intent_ of calling them from anywhere. Of course, because they are currently callable from anywhere, code will end up using it that way.