From: James Coglan Date: 2009-08-06T21:16:36+09:00 Subject: Re: Kernel's module methods? --001636c5acf8196fce04707817dc Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit 2009/8/6 Brian Candler > 7stud -- wrote: > > How come you can call Kernel methods without a receiver? > > If I understand it rightly: because self is the top level object 'main', > and main is an *instance* of Object. I think the point being raised is that when you mix a module into a class, the class gains the module's instance methods, but not its module/singleton methods. So it seems that the only way you'd be able to call Kernel's module methods without a receiver would be if `self` were equal to `Kernel`. But seeing as how you can call these methods sans receiver anywhere in your program, I assume the Kernel methods are given special treatment and don't follow the usual scoping rules for method calls. Another way you could do this is by having all objects inherit from Kernel's eigenclass, but that's also not allowed in user code so again this points at special treatment of Kernel code in the Ruby VM. -- James Coglan http://jcoglan.com --001636c5acf8196fce04707817dc--