Feature #7363


Remove the global Pathname() method

Added by aef (Alexander E. Fischer) about 10 years ago. Updated about 10 years ago.

Target version:


About a year ago I sumbitted an not yet accepted patch for Ruby on GitHub which deprecates the global Pathname() method and adds the .[] operator to the Pathname class. The patch got ignored, supposedly because I didn't post it here.

I think poisoning the global namespace with methods named after classes should be considered bad style. Instead, all related methods should lie below the Class' namespace. I hope you share that opinion.

As some User once suggested that probably only collection type classes (e.g. Set) should have a .[] operator, I'm no longer proposing to add .[] instead to Pathname.

If you like the idea, please let me know. I will modify the patch then.


7363.patch (1.67 KB) 7363.patch zzak (Zachary Scott), 11/19/2012 07:12 AM

Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #7378: Adding Pathname#writeClosedakr (Akira Tanaka)06/02/2012Actions

Updated by Anonymous about 10 years ago


First off: +1 on your request about the Pathname(). Although I don't see
the the real problem with it being named after a class. However, I don't
think it's necessary to have a shortcut which is four characters shorter
than the thing it shortens (afaict it is a shorthand of -
does it really hurt to write those four characters?). Also, another
problem I see with it is that it doesn't conform with the usual method
naming scheme.

Secondly, I regard Pathname as a collection - in the exact same way I
regard Dir as a collection; a collection of path names that is. And I
think others do too. So I don't see why we shouldn't have said method.
It could even alias to ::glob as Dir[] does; that would give some
consistency (though I wouldn't mind if we'd continue not to have ::[]).

P.S.: If I replied wrong in any way, please let me know, as I couldn't
find a guide on how to reply to issues (if it's any different than
replying like in a "regular" mailing list). Thanks!

Updated by drbrain (Eric Hodel) about 10 years ago

(({Pathname()})) matches (({Integer()})), (({Array()})), (({URI()})), etc. I would prefer to keep (({Pathname()})) in the tradition of these other methods.

Updated by zzak (Zachary Scott) about 10 years ago

Adding patch from github.

Updated by mame (Yusuke Endoh) about 10 years ago

  • Status changed from Open to Rejected

As drbrain said, this is the convention in Ruby. There is no reason to hate only Pathname.
Because of compatibility, it is impossible to remove all methods that is named after the corresponding class, i.e., Integer, Array, etc.

Yusuke Endoh


Also available in: Atom PDF