From: Charles Oliver Nutter Date: 2011-01-10T16:33:52+09:00 Subject: [ruby-core:34296] Re: Avoiding $LOAD_PATH pollution Sorry, missed this email until it was bumped recently... On Fri, Aug 27, 2010 at 12:43 AM, Eric Hodel wrote: > Last year Nobu asked me to propose an API for adding an object to > $LOAD_PATH (instead of a String) that could do the work of finding paths > to load. ��The reason was to avoid the pollution of $LOAD_PATH that > RubyGems causes as it activates multiple gems. > > I have created a proof-of-concept implementation called fancy_require: > > http://github.com/drbrain/fancy_require > > specifically: > > http://github.com/drbrain/fancy_require/blob/master/lib/fancy_require.rb The base protocol seems fine to me. I think you and I discussed it on IRC at some point. I like its simplicity. I do have a concern for the additional overhead it adds to all requires. case/when matching does a dispatch to ===, so that's a dyncall for every element at the very least. Probably could be short-circuited in the C code. The loaded? implementation is broken like gem_prelude on systems with case-insensitive filesystems like OS X and Windows. JRuby just added a change to "require" that the $" search is done case-insensitively when on a case-insensitive filesystem, but it's an experimental change. We made it originally to work around problems in gem_prelude that disappeared when we wiped out gem_prelude... The specified protocol would also greatly simplify logic in JRuby to load files from URLs and classloader resources. Where currently we have special-cased logic to search those types of artifacts, with your change we'd simply register "finders" in the load path that can handle them. This probably could also tie into the Ruby Archive RSoC project, allowing MRI to also load code from archives. I did not follow that project closely enough to know its status. - Charlie