Constants are viewed
- outward in the ads of lexically spanning modules
- up in the inheritance chain of the current module declaration
So let's just do what Ruby does:
- look in lexically closed module declarations: easy - no module declarations
- : , ... ? , , ,
class Object - Object FOO, Kernel BasicObject.
: . FOO. FOO , .
[API Ruby reflection , : # 1 Module.nesting, # 2 () Module.nesting.first.ancestors.]
: , module_eval ? , ! , , , . .
, : , , instance_eval , , , module_eval . , String , Module.nesting , , !