From: David Masover Date: 2011-06-24T04:07:47+09:00 Subject: Re: RFC - One word alias for require_relative On Wednesday, June 22, 2011 10:25:37 PM Ilias Lazaridis wrote: > On 21 Ιούν, 21:55, Iñaki Baz Castillo wrote: > > 2011/6/20 Ilias Lazaridis : > > >> False. > > > > > > [...] - (not readed, 'cause it's anyway biased babbling) > > > > Sorry??? > > If someone is usually not concise and straight to the point, and > "wraps" technical information with personal-level babbling, then I > simply stop to read him. Yet take the time to post "Babbling", without actually confirming that it was. Still, I didn't even write as much "personal" stuff as in this paragraph, or the paragraph I quoted above. I just responded directly to your points. When you do the same... > > the given argument is really GOOD: > Ok, I'll take a look: [snip] > In that case, the bang-name "require!" would not be adequate for > "require_relative". ...when you do the same, we get somewhere. > Possibly it would be easier to add behaviour of "require": > > require "./filename" #=> loads relative to $Dir.pwd (process working > directory) > > require ":/filename" #=> loads relative to the file-directory > > Possibly there's somewhere a standard for this. That's not a bad idea. I still don't see the point of having this over require_relative, and we can no longer require files which begin with a colon character. It certainly seems less readable than require_relative, especially when I usually read a colon prefix as "Symbol". Still, it at least doesn't break much (who has a file named :foo.rb, really?). So, just for fun, here's an implementation: module Kernel def require_with_colon path if path =~ /^:(.*)/ require_relative $1 else require_without_colon path end end alias require_without_colon require alias require require_with_colon end Or, to pollute the namespace less: module Kernel require_without_colon = method :require define_method :require do |path| if path =~ /^:(.*)/ require_relative $1 else require_without_colon[path] end end end I'll still be using require_relative, myself, but if people end up actually using either of the above, I'd think that'd be a good case for getting it into core, if that's what you want to do.