From: Jams Date: 2012-06-13T22:20:34+09:00 Subject: Re: require_relative? why didn't we "relative do" On Jun 12, 2012, at 9:34 PM 6/12/12, Intransition wrote: > I wonder if it would been better if we had gone another route with the whole `#require_relative` thing. Instead of a special require method, we could have a method that adds the current file's directory to the top of the $LOAD_PATH temporarily while a block executes. > > For example, lets say we have a library `fruit_basket' with: > > lib/ > fruit_basket.rb > fruit_basket/ > grape.rb > orange.rb > > Then in `fruit_basket.rb`: > > relative do > require 'grape' > require 'orange' > end > > Assuming `#relative` to be the name of such a method. > > This is actually quite easy to implement in pure Ruby and would not have required a C-based patch to Ruby core. > > Hey Intransition. you might have better luck emailing ruby-core if you're interested in this an can't work it out. Have you looked through the ruby-lang archives? The first hit I found for require_relative was this: http://www.ruby-forum.com/topic/148978 which seems to indicate there wasn't much discussion about the functionality. What's cool is that it also shows that require_relative was originally ruby code, not C. Assuming that it was rewritten in C (I haven't checked), I imagine it was to ensure performance. 1.9 had a lot of performance improvements over 1.8. Jams