Hi,

At Sat, 31 May 2003 00:09:40 +0900,
Yukihiro Matsumoto wrote:
> |> I think autoload should require X::XXX to be defined, so that should
> |> raise exception for this case, because X::XXX is referencing ::XXX
> |> which can be seen via X.  The confusion was caused by X::XXX as ::XXX
> |> if there's no X::XXX.  This has its own reason but still confusing.
> |
> |At first I thought so too.  But, in this case, refereced is
> |X::XXX which is exactly autoloaded one but not ::XXX.
> 
> ??
> 
> 1  module X
> 2    autoload :XXX, "x.rb"
> 3  end
> 4  p X::XXX'
> 
> 
> On line 2, autoload is declared, so that "x.rb" will be loaded when
> X::XXX is referenced.  And I believe "x.rb" should define XXX under X,
> not ::XXX.

Yes, it should be X::XXX now.

> On line 4, X::XXX is referenced, so that autoload is executed, "x.rb"
> is loaded.  Then, in autoload process, it should check if X::XXX is
> defined.  In this case, x.rb does not define XXX under X.  This means
> autoload process should raise NameError.  Right?

But ::XXX is defined, and it is visible as X::XXX via X.  wrong?

I guess this is another (old) problem.

-- 
Nobu Nakada