From: Shadowfirebird Date: 2008-07-24T21:41:13+09:00 Subject: Re: circular 'require' Ah! Thank you! That's brilliant! On Thu, Jul 24, 2008 at 1:19 PM, Calamitas wrote: > On Thu, Jul 24, 2008 at 10:02 AM, Shadowfirebird > wrote: >> 1) require is mildly broken (a). It doesn't set $" until after the >> given file is loaded. This can lead to errors when you have a >> circular call of requires. If it set $" first, circular references >> would just be ignored. Of course, you should never actually *need* to >> have circular 'require' referefences, but: see my next point. > > Require isn't broken. Essentially, you could say that require has its > internal version of $" that is set before executing a file (although > as Stefano pointed out, it is maintained as the difference with the > externally visible $"). > > Require works as advertised. But "ruby test1.rb" doesn't do a require > of test1.rb, "ruby -r test1.rb" does that. "ruby test1.rb" simply > executes the file without looking at or setting $", which is what > #load does too. This is by design. If you explicitly set $" in > test1.rb, you essentially give a load of that file some of the > semantics of a require. > > Peter > > -- 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