From: Stephen Touset Date: 2011-12-01T10:16:51+09:00 Subject: [ruby-core:41421] [ruby-trunk - Feature #5653] "I strongly discourage the use of autoload in any standard libraries" (Re: autoload will be dead) Issue #5653 has been updated by Stephen Touset. One thing to keep in mind is that `const_missing` *cannot* be used to replicate `autoload` currently due to Ruby cascading constant lookup to the Object namespace. Example: >> class Foo; end >> class Bar; end >> class Baz | autoload :Foo, 'baz/foo' | | def self.const_missing(name) | require "baz/#{name.downcase}" | end | end >> Baz::Foo LoadError: cannot load such file -- baz/foo >> Baz::Bar => Bar You can see here that Baz::Foo wasn't detected (even though there's a Foo in the Object namespace) and the autoload triggers. Baz::Bar, however, resolves to Object::Bar and the `const_missing`-based autoload does not fire as expected. ---------------------------------------- Feature #5653: "I strongly discourage the use of autoload in any standard libraries" (Re: autoload will be dead) http://redmine.ruby-lang.org/issues/5653 Author: Yukihiro Matsumoto Status: Open Priority: Normal Assignee: Category: lib Target version: 2.0.0 Hi, Today, I talked with NaHi about enhancing const_missing to enable autoload-like feature with nested modules. But autoload itself has fundamental flaw under multi-thread environment. I should have remove autoload when I added threads to the language (threads came a few months after autoload). So I hereby declare the future deprecation of autoload. Ruby will keep autoload for a while, since 2.0 should keep compatibility to 1.9. But you don't expect it will survive further future, e.g. 3.0. I strongly discourage the use of autoload in any standard libraries. matz. -- http://redmine.ruby-lang.org