atom feed6 messages in org.ruby-lang.ruby-talkRe: warning: toplevel constant XX ref...
FromSent OnAttachments
ThomasSep 2, 2003 2:51 am 
ThomasSep 3, 2003 2:21 am 
Yukihiro MatsumotoSep 3, 2003 5:41 am 
ThomasSep 4, 2003 3:25 am 
Yukihiro MatsumotoSep 4, 2003 4:56 am 
Thomas SondergaardSep 4, 2003 8:45 am 
Subject:Re: warning: toplevel constant XX referenced by YY::XX
From:Thomas Sondergaard (
Date:Sep 4, 2003 8:45:47 am

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.