From: Shadowfirebird Date: 2008-07-25T04:19:47+09:00 Subject: Re: circular 'require' Pit, your idiom of putting require inside the class definition appears to be considerably more robust than my half-baked notions. On Thu, Jul 24, 2008 at 3:23 PM, Pit Capitain wrote: > 2008/7/24 Shadowfirebird : >> I apologise if I seem to be complaining. > > No need to apologize, everybody should have the right to complain. I > thought that you either hadn't read or tried what I wrote in my first > mail and therefore got the (in my view) false impression that require > was broken. That's the reason for my maybe too harsh an answer, sorry. > >> Pit, I think your solution is interesting because it imbeds a class >> definition inside a class. Are there any downsides to that? > > Calling require inside a class definition or even inside a method > doesn't embed the loaded constants (class names are constants too) > into the "calling" class. It just changes the time when require is > called. In your case, it would mean that require is called *after* > creating the class Root, so that the required file can use that name. > > Sometimes I've seen code that requires certain files only if some > method is called which needs the required functionality: > > def method_with_special_requirements > require "rarely_used_library" > use_the_required_functionality > end > > This avoids the overhead of loading all the files everytime, even if > the funcationality isn't used at all. > > Regards, > Pit > > -- Me, I imagine places that I have never seen / The colored lights in fountains, blue and green / And I imagine places that I will never go / Behind these clouds that hang here dark and low But it's there when I'm holding you / There when I'm sleeping too / There when there's nothing left of me / Hanging out behind the burned-out factories / Out of reach but leading me / Into the beautiful sea