Hi,

I have following found. If I define one module *in* another one, the
innermost is only accessible via the outer one. That means:

   $ ruby -v 
   ruby 1.5.3 (2000-03-15) [i586-linux] 

   $ ruby
   module Foo
     module Bar
     end
   end

   p Foo::Bar  # This would be ok!
   p Bar       # This of course not, as Bar is part of Foo.
   ^D
   Foo::Bar    # Ok!
   -:7: uninitialized constant Bar (NameError)  # Yep!

This behavior as expected (at least as *I* expect it ;-)

But if I put the definition of the inner module 'Bar' in a file on its
own called e.g. 'mBar.rb' and 'require' this file during module
definition of 'Foo', 'Bar' will be known both within 'Foo' and outside
of it:

   $ cat mBar.rb
   module Bar
   end

   $ ruby
   module Foo
     require "mBar"
   end
   
   p Foo::Bar   # This should be ok!
   p Bar        # And this should be wrong, shouldn't it?
   ^D
   Bar          # Ok :-)
   Bar          # Oops! :-(

I would like to know, if this is a bug or a feature? If it is a
feature, does that mean I can count of it? If it is a bug, I have
another problem I would tell you then!

Ciao,
\cle

-- 
Clemens Hintze  mailto: c.hintze / gmx.net