Feature #7363

Remove the global Pathname() method

Added by Alexander E. Fischer over 1 year ago. Updated over 1 year ago.

[ruby-core:49377]
Status:Rejected
Priority:Normal
Assignee:-
Category:lib
Target version:-

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.

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


Related issues

Related to ruby-trunk - Feature #7378: Adding Pathname#write Closed 06/02/2012

History

#1 Updated by Anonymous over 1 year 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!

#2 Updated by Eric Hodel over 1 year ago

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

#3 Updated by Zachary Scott over 1 year ago

Adding patch from github.

#4 Updated by Yusuke Endoh over 1 year 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

Also available in: Atom PDF