From: Trans Date: 2005-09-16T09:16:34+09:00 Subject: Re: Module.nesting -> Kernel#nesting Trans wrote: > > But __FILE__ is a token recognized by the parser. It is neither a > > constant nor a method of any module, including Kernel. > > True. But if you were to try to define it yourself it woul be a Kernel > module. > > Anyway, I've come back to this old thread b/c I realize now, why > exactly this would be more approriate as a Kernel method and not a > Module method: the definition requires a "Binding.of_caller" in order > to work --ie. if one were to try to do it in ruby themselves. So > underthehood it must be doing the same. Since Binding.of_caller is > considered "not good" (do I understand correctly that matz has > declined this functionality for Ruby?) then this method goes against > that grain. > > How did I realize this? I was trying to write an Ruby interpolate > method as a String module function. And for the same reason it was not > possible --I had to put it in Kernel. Well, I'll correct myself. Techincally, you still need Binding.of_caller using Kernel. It's just that Kernel's modus operandi is functionality unversally present, so it seems like the right place. T.