In message "Re: [ruby-cvs] ruby, ruby/lib: * eval.c (ev_const_defined, ev_const_get), variable.c"
on 03/05/30, nobu.nokada / softhome.net <nobu.nokada / softhome.net> writes:
|> 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.
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?
matz.