Project

General

Profile

Feature #14138

Define English.rb aliases by default and eliminate the library

Added by headius (Charles Nutter) about 1 year ago. Updated about 1 year ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Target version:
-
[ruby-core:83930]

Description

There are many good reasons to simply define all the English.rb global aliases at boot:

  • JRuby has done it for years with zero reported bugs.
  • Rubinius has done it for years with zero reported bugs.
  • Globals are in general discouraged, so the likelihood of collision with a user library is very low.
  • The globals that remain are better indicated by using the long name rather than the Perl-esque short names.
  • One less library to maintain.

The only argument to not do this seems to be the collision concern, but that has not affected hundreds of users of JRuby and Rubinius over the past decade. I think we're safe.

This would be ideal for 2.5, if it's not too late, since this is the big "gemifying" release. Eliminating English.rb would fit into that well.


Related issues

Related to Ruby trunk - Bug #14240: warn four special variables: $; $, $/ $\OpenActions

History

Updated by MSP-Greg (Greg L) about 1 year ago

Charles,

+1

You mentioned several good points. I've got them doc'd in the 'Top Level Namespace' of my doc site so I could find the source, it would be nice if the comments could move there and replace the globals.rdoc file. Along with RDoc picking them up somehow...

Updated by shevegen (Robert A. Heiler) about 1 year ago

I agree too so +1 from me.

Similar to pp by default, I shied away from suggesting the above
because I assumed that there may be speed issues.

If, however had, there are no considerable speed penalties then,
similar to pp, I'd be all in favour of this.

I never had any concern about collision use myself in the last
~10-15 years of using ruby, in regards to English. But the
extra require line indeed was an obstacle to making use of
English.rb more for me (mostly due to convenience or also
because I may forget it).

Updated by matz (Yukihiro Matsumoto) about 1 year ago

  • Status changed from Open to Closed

We are discussing removing those weird global variables (for Ruby3).
Even if we cannot remove them, we'd like to provide the alternative way to access the info (e.g. Regexp.last_match for $~). If any of those variables will survive, I'd love to provide the aliases for those variables. Wait for Ruby3.

I'd close the issue for now.

Matz.

#4

Updated by matz (Yukihiro Matsumoto) about 1 year ago

  • Related to Bug #14240: warn four special variables: $; $, $/ $\ added

Also available in: Atom PDF