From: Thomas Sondergaard Date: 2003-09-05T00:46:09+09:00 Subject: Re: warning: toplevel constant XX referenced by YY::XX > Yes, but I think we need to wait for a while to make a transition. > So can you wait for a moment, probably until 1.8.1? Yes, sure. > By the way, you may have problems also for constant name conflict. > > module Foo > Foo1 = 42 > end > > class Bar > include Foo > def Bar.const_missing(id) > id > end > end > p Bar::Foo1 > p Bar::Foo2 > > Is it OK for you? Strictly speaking this is a problem for me, but not something that is likely to cause too many problems in the real world. As I see it const_missing and method_missing are called too late to serve their purpose correctly. They should be called before looking in parent scopes. The way it works now is probably a pragmatic (in the generic sense) trade off, that avoids trading too much performance for a niche feature. Maybe the real solution is to introduce a new built-in object, say, DynamicObject that invokes the *_missing methods earlier in the resolution sequence. This would require that method invocation and constant lookup suffered one extra layer of indirection, but it could be implemented in C and probably wouldn't make a noticable performance difference. Or maybe this "dynamicity" property could just be a flag on the class, I dunno. This is just me thinking out loud. You are the language expert, I am just a hack. Cheers, Thomas