From: Aaron Patterson Date: 2013-08-17T13:58:58-07:00 Subject: [ruby-core:56704] Re: [ruby-trunk - Feature #8781] Use require_relative() instead of require() if possible On Sat, Aug 17, 2013 at 09:00:34PM +0900, Nobuyoshi Nakada wrote: > (13/08/17 13:13), Aaron Patterson wrote: > > First, it *is* a real use case (as in, people actually use it in *real* > > projects): > > > > [aaron@higgins ruby (trunk)]$ git grep require_relative | grep '\.\.' | wc -l > > 45 > > [aaron@higgins ruby (trunk)]$ > > It's only in test directory, and almost is test/ruby/envutil.rb. > > I agree that require_relative fits something but may not other. > That example tells us that envutil.rb shouldn't be bound in test/ruby. > > > Again, "foo.rb" is completely independent of the filesystem. The files > > it depends on did not change, so it did not have to change. > > > > I am uncertain how to make the coupling between "require_relative" and > > the filesystem more clear than this. > > But I don't think your point enough to prohibit to use require_relative. I don't think it should be prohibited. I am pointing out why I don't use it (namely LOAD_PATH hacking). > Why move a file but not edit it? I am using "file moving" as a way to demonstrate how `require_relative` couples your file to its location on the file system. `require` does not have this coupling. > An author can use it when one thinks it is useful, it's the author's choice. > This proposal is just a proposal, but not mandatory. Yes. I think it's fine, I just don't want to use it. Are there no more ways to speed up `require`? -- Aaron Patterson http://tenderlovemaking.com/