Hi,

2010/1/22 Benoit Daloze <eregontp / gmail.com>:
> Hi,
>> In similar, you can require the same library twice.
>>
>>  require "foo"
>>  require "foo"
>>
> Excuse me, but at least in 1.9,
> p require './test' #=> true
> p require './test' #=> false
> (the same happen with a stdlib, like benchmark of course)
>
> It's not loaded the second time. And it's very harmful to load 2 times
> the same file, because it will redefine every method and constant...

Yes.  I meant to say neither exception nor warning.
OTOH, curcular require yields warning:


foo.rb
  require "./bar"

bar.rb
  require "./foo"

$ ruby19 -W2 foo.rb
/home/mame/work/ruby/foo.rb:1: warning: loading in progress, circular
require considered harmful - /home/mame/work/ruby/bar.rb
        from foo.rb:1:in `<main>'
        from foo.rb:1:in `require'
        from /home/mame/work/ruby/bar.rb:1:in `<top (required)>'
        from /home/mame/work/ruby/bar.rb:1:in `require'
        from /home/mame/work/ruby/foo.rb:1:in `<top (required)>'
        from /home/mame/work/ruby/foo.rb:1:in `require'


... Ah, I get Roger's point now.


bad.rb:
  require $0
  p :foo

$ ruby19 ./bad.rb
:foo
:foo


I don't know this is a bug or not, but I guess that Kurt is right.

-- 
Yusuke ENDOH <mame / tsg.ne.jp>