----------------8<----------------cut-here----------------8<----------------
RCR: #const_name_is
Currently, doing Foo=bar is mostly equivalent to:
current_module.const_set(:Foo,bar)
This is a proposal to append this notification to the behaviour:
if bar.respond_to? :const_name_is
bar.const_name_is(:Foo,current_module)
end
Possibly that this notification should be done from inside #const_get.
In general, a method const_name_is would register the values passed by the
first such call, and consider that as its path in the tree of constants.
Here is how things can get kludged up without this feature:
module SomeModule
Foo = Bar.new(:Foo,self,*other_args)
end
or else:
module SomeModule
Foo = Bar.new(*other_args)
end
[and at the end of the file:]
SomeModule.constants.each {|name|
obj = SomeModule.const_get(name)
next unless Bar===obj
obj.const_name_is name, SomeModule
}
----------------8<----------------cut-here----------------8<----------------
matju