Issue #7975 has been reported by yimutang (Joey Zhou). ---------------------------------------- Bug #7975: Why __dir__, not __DIR__ https://bugs.ruby-lang.org/issues/7975 Author: yimutang (Joey Zhou) Status: Open Priority: Normal Assignee: Category: Target version: ruby -v: 2.0 There's a __FILE__ in Ruby 1.x, no __file__ Why __dir__ in Ruby 2.0 is downcase? It's not consistent.
on 2013-02-27 02:23
on 2013-02-27 02:32
Issue #7975 has been updated by zzak (Zachary Scott). Status changed from Open to Rejected see #3346 ---------------------------------------- Bug #7975: Why __dir__, not __DIR__ https://bugs.ruby-lang.org/issues/7975#change-37124 Author: yimutang (Joey Zhou) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: 2.0 There's a __FILE__ in Ruby 1.x, no __file__ Why __dir__ in Ruby 2.0 is downcase? It's not consistent.
on 2013-02-27 02:49
Issue #7975 has been updated by yhara (Yutaka HARA). That is becuase __dir__ is a method, whereas __FILE__ is not. $ ruby -ve 'p Kernel.methods' ruby 2.0.0p0 (2013-02-24 revision 39474) [x86_64-darwin12.2.1] [:sprintf, :format, :Integer, :Float, :String, :Array, :Hash, :warn, :raise, :fail, :global_variables, :__method__, :__callee__, :__dir__, :eval, ..... __dir__ is prefered to avoid adding a new keyword (see #1961.) ---------------------------------------- Bug #7975: Why __dir__, not __DIR__ https://bugs.ruby-lang.org/issues/7975#change-37128 Author: yimutang (Joey Zhou) Status: Rejected Priority: Normal Assignee: Category: Target version: ruby -v: 2.0 There's a __FILE__ in Ruby 1.x, no __file__ Why __dir__ in Ruby 2.0 is downcase? It's not consistent.
on 2013-02-27 12:20
Issue #7975 has been updated by wardrop (Tom Wardrop).
=begin
We did come to any sort of resolution to the naming inconsistency
between __dir__/__method__ and __FILE__/__LINE__ in any of those
mentioned issues.
Should we not add __file__ and __line__ as methods, and perhaps
deprecate the keywords __FILE__ and __LINE__. This would keep it
consistant with all the other double-underscore methods. To most
developers who perhaps do not know Ruby as intricately as most of the
people on this issue tracker, the inconsistency between __dir__ and
__FILE__ is not just confusing by name, but the fact that one is a
method and one isn't, is doubly confusing. Definitely not principle of
least surprise.
This needs to be addressed in my opinion, either through deprecation of
__FILE__ and __LINE__, or by keeping those keywords and simply creating
Kernel method equivalents for the sack of a consistant API.
While on the topic, someone also suggested in one of those previous
issues, to give __dir__ an optional join argument, so you could do
something like this:
(({__dir__('somefile.txt') # => /Users/admin/somefile.txt}))
I'd predict that at least 90% of use cases for __dir__ will involve
joining it to another path or filename. I can't see any harm in adding
this. The naming inconstancies are my main concern however.
=end
----------------------------------------
Bug #7975: Why __dir__, not __DIR__
https://bugs.ruby-lang.org/issues/7975#change-37146
Author: yimutang (Joey Zhou)
Status: Rejected
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 2.0
There's a __FILE__ in Ruby 1.x, no __file__
Why __dir__ in Ruby 2.0 is downcase?
It's not consistent.
Please log in before posting. Registration is free and takes only a minute.
Existing account
(Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
Log in with Google account | Log in with Yahoo account
No account? Register here.