Feature #7363
closedRemove the global Pathname() method
Description
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.
https://github.com/ruby/ruby/pull/61
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.
Files
Updated by Anonymous about 12 years ago
Hi,
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 Pathname.new -
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 12 years ago
=begin
(({Pathname()})) matches (({Integer()})), (({Array()})), (({URI()})), etc. I would prefer to keep (({Pathname()})) in the tradition of these other methods.
=end
Updated by zzak (zzak _) about 12 years ago
- File 7363.patch 7363.patch added
Adding patch from github.
Updated by mame (Yusuke Endoh) almost 12 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 mame@tsg.ne.jp