[#56333] [CommonRuby - Feature #8723][Open] Array.any? predicate returns true for empty array. — "nurettin (Nurettin Onur TUGCU)" <onurtugcu@...>

12 messages 2013/08/02

[#56368] [ruby-trunk - Bug #8730][Open] "rescue Exception" rescues Timeout::ExitException — "takiuchi (Genki Takiuchi)" <genki@...21g.com>

15 messages 2013/08/04

[#56407] [ruby-trunk - misc #8741][Open] email notification on bugs.ruby-lang.org is broken — "rits (First Last)" <redmine@...>

18 messages 2013/08/05

[#56524] [ruby-trunk - Bug #8770][Open] [PATCH] process.c: avoid EINTR from Process.spawn — "normalperson (Eric Wong)" <normalperson@...>

19 messages 2013/08/10

[#56536] [ruby-trunk - Feature #8772][Open] Hash alias #| merge, and the case for Hash and Array polymorphism — "trans (Thomas Sawyer)" <redmine@...>

24 messages 2013/08/11

[#56544] [ruby-trunk - Bug #8774][Open] rb_file_dirname return wrong encoding string when dir is "." — jiayp@... (贾 延平) <jiayp@...>

10 messages 2013/08/11

[#56569] [ruby-trunk - Feature #8781][Open] Use require_relative() instead of require() if possible — "ko1 (Koichi Sasada)" <redmine@...>

31 messages 2013/08/12
[#56582] [ruby-trunk - Feature #8781] Use require_relative() instead of require() if possible — "drbrain (Eric Hodel)" <drbrain@...7.net> 2013/08/12

[#56584] Re: [ruby-trunk - Feature #8781] Use require_relative() instead of require() if possible — SASADA Koichi <ko1@...> 2013/08/12

(2013/08/13 2:25), drbrain (Eric Hodel) wrote:

[#56636] Re: [ruby-trunk - Feature #8781] Use require_relative() instead of require() if possible — Aaron Patterson <tenderlove@...> 2013/08/16

On Tue, Aug 13, 2013 at 07:38:01AM +0900, SASADA Koichi wrote:

[#56634] [ruby-trunk - Feature #8788][Open] use eventfd on newer Linux instead of pipe for timer thread — "normalperson (Eric Wong)" <normalperson@...>

11 messages 2013/08/16

[#56648] [ruby-trunk - Bug #8795][Open] "Null byte in string error" on Marshal.load — "mml (McClain Looney)" <m@...>

17 messages 2013/08/16

[#56824] [ruby-trunk - Feature #8823][Open] Run trap handler in an independent thread called "Signal thread" — "ko1 (Koichi Sasada)" <redmine@...>

14 messages 2013/08/27

[#56878] [ruby-trunk - misc #8835][Open] Introducing a semantic versioning scheme and branching policy — "knu (Akinori MUSHA)" <knu@...>

11 messages 2013/08/30

[#56890] [ruby-trunk - Feature #8839][Open] Class and module should return the class or module that was opened — "headius (Charles Nutter)" <headius@...>

26 messages 2013/08/30

[#56894] [ruby-trunk - Feature #8840][Open] Yielder#state — "marcandre (Marc-Andre Lafortune)" <ruby-core@...>

14 messages 2013/08/30

[ruby-core:56871] [ruby-trunk - Feature #8834] Kernel#load_relative

From: "phluid61 (Matthew Kerwin)" <matthew@...>
Date: 2013-08-30 03:02:37 UTC
List: ruby-core #56871
Issue #8834 has been updated by phluid61 (Matthew Kerwin).


sawa (Tsuyoshi Sawada) wrote:
> > phluid61
> 
> I think what you wrote is the other way around. The only-once feature is due to the division of labor, not the other way around. See this:
> 
> http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-core/21562

I understand. I had a slightly different definition of "script" in my head.  I'd forgotten that require doesn't need an extension (and can thus load any .rb, .so, etc. file), where load requires the extension.

In that vein, I personally have never seen anyone use require/_relative when they should have used load.  I've never seen a project that has "scripts" that aren't library code, even if they're only project-specific libraries.

Note: I'm not arguing against #load_relative exactly, I've just never seen a need.  Maybe its existence, and an education campaign, can make it useful.
----------------------------------------
Feature #8834: Kernel#load_relative
https://bugs.ruby-lang.org/issues/8834#change-41423

Author: sawa (Tsuyoshi Sawada)
Status: Open
Priority: Normal
Assignee: 
Category: 
Target version: 


The intended difference between `Kernel#require` and `Kernel#load` is that the former is for external libraries and the latter is for Ruby scripts internal to the project. Considering this fact, `load` should be more likely than `require` to be used in a situation where you want to call a file through a relative path. Strangely, there is `Kernel#require_relative`, but no `Kernel#load_relative`. I request `Kernel#load_relative`. It is even more necessary than `Kernel#require_relative`.

It seems to me that people are using `Kernel#require_relative` when they want to use a relative path, even in the context where they are supposed to use `load` because of the lack of `Kernel#load_relative`. I don't think this is a good practice. Furthermore, in cases where you have a file without a `.rb` or other extention that you want to call via a relative path, there is no good way to do it.



-- 
http://bugs.ruby-lang.org/

In This Thread