Project

General

Profile

Actions

Feature #5977

closed

Remove $, and avoid perlish global variables

Added by Eregon (Benoit Daloze) about 12 years ago. Updated about 12 years ago.

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

Description

Hello,

As I mentioned at RubyConf, I would like the $, global variable to be removed for 2.0.

I would like to avoid "perlish" global variables in general, but I think many can't be removed for compatibility, and a few are actually useful shortcuts (mostly to the pattern matching variables). They are nice for golfing and small scripts, but I believe they hurt bigger scripts/code.

$, is used as the default separator for Array#join (and Kernel#print), and I think it causes more harm than good:

  • I believe many ruby codes would fail (different and unexpected output) when setting $, , because it means a simple ary.join is not deterministic: you need ary.join('') which is long and quite unexpected for a "default" behavior.
  • The behavior would be much clearer (a simple method with a sensible default) and so the documentation.
  • It's mostly unused, and except for trivial scripts it will just be complicated to manage as it impacts globally the output.

What do you think?


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14240: warn four special variables: $; $, $/ $\Closedjeremyevans0 (Jeremy Evans)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0