From: Robert Klemme Date: 2009-11-25T07:21:03+09:00 Subject: Re: [ANN] autoloader, version 0.0.2 On 11/24/2009 07:06 PM, David Masover wrote: > On Tuesday 24 November 2009 06:43:20 am Robert Klemme wrote: >> Btw, one disadvantage of using a directory glob is that it is far more >> expensive than the standard autoload because the standard autoload >> does not need any file system IO before any file is loaded. Using >> directory globbing on the other hand requires to at least read the >> directory which may slow down startup of a script considerably. > > Except that standard autoload is more work for me, and nearly defeats the > point. Trading requires for autoloads directly makes things harder to debug > without making them easier to write -- it _only_ optimizes start time. Yeah, absolutely. If your major goal is to simplify script writing this is definitive a good option. I just wanted to point out that the convenience comes at a price. :-) > One possibility would be to write a script which attempts to automatically > generate these autoload statements, but store them statically in a single > file. The main reason I don't like that is, you've now added a "compile" step > to a script. It might work as an option, maybe a "development" vs "production" > mode. Yeah, ugly. > Another possibility is to override const_missing, but that gets complex fast, > as Rails shows. > > Also, keep in mind that the directory IO is shallow. That is, if you tell it > to autoload foo, it won't touch anything in foo/bar. If you create a file > bar.rb which requires autoload, it will look at foo/bar, but only once Bar is > autoloaded. > > Thanks for the feedback! You're welcome! Thanks for taking the time to digest it. Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/