From: Florian Frank Date: 2005-08-13T09:11:11+09:00 Subject: Re: LibInject 0.1.0: Small Pieces Smooshed Together Jim Weirich wrote: >My personal style (in general) is to put all the requires at the top level >at the beginning. However in RubyGems we use the above idiom often to >avoid requiring things that are not needed. > You can have both, if you do autload :OptionParser, 'optparse' at the beginning. 'optparse' is only loaded, when the OptionParser constant is accessed and doesn't exist. It's also possible to do something like module AllMyStuff module A autoload :MyClass, 'all_my_stuff/a/my_class' end end and a = AllMyStuff::A::MyClass.new for more complicated setups, because autoload is a method of Kernel and Module. -- Florian Frank