Project

General

Profile

Actions

Feature #7363

closed

Remove the global Pathname() method

Added by aef (Alexander E. Fischer) almost 12 years ago. Updated almost 12 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
[ruby-core:49377]

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

7363.patch (1.67 KB) 7363.patch zzak (zzak _), 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 almost 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) almost 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 _) almost 12 years ago

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0