Feature #3346

__DIR__ revisted

Added by trans (Thomas Sawyer) over 10 years ago. Updated almost 8 years ago.

Target version:


I'd like to know why DIR was rejected? I use File.dirname(FILE) all the time, and I frequently see others do so as well. #relative_require is helpful but it covers only one specific use case --and probably not the most common one. I am often using File.dirname(FILE) in build scripts, when I am loading examples for tests, and when I load output templates or other pluggable modules that reside relative to my code. For something so common, having to clutter my code with a 22 character sequence, when an perfectly obvious 7 character sequence would do semms very uncharacteristic of Ruby, which is usually quite concise. Indeed, it is not uncommon to see code that defines a constant such as DIR = File.dirname(FILE) when it will be used more than once because it quickly becomes an eye-sore. For these reasons I hope you will reconsider the earlier rejection.


3346.pdf (41.5 KB) 3346.pdf 1-page presentation slide for the feature request meeting ([ruby-dev:45708]) yhara (Yutaka HARA), 06/30/2012 02:13 AM
__dir__.patch (1.38 KB) __dir__.patch authorNari (Narihiro Nakamura), 11/01/2012 11:02 PM

Related issues

Related to Ruby master - Bug #7729: __dir__ returns a absolute dir pathRejectedauthorNari (Narihiro Nakamura)01/23/2013Actions
Is duplicate of Ruby master - Feature #1961: Kernel#__dir__Closedmatz (Yukihiro Matsumoto)08/19/2009Actions
Has duplicate Ruby master - Bug #7975: Why __dir__, not __DIR__Rejected02/27/2013Actions
Has duplicate Ruby master - Feature #8098: Add __DIR__ to compliment __FILE__Rejected03/15/2013Actions

Also available in: Atom PDF