Project

General

Profile

Actions

Bug #7406

closed

English.rb says that $_ is thread-local, but it is frame-local

Added by headius (Charles Nutter) about 12 years ago. Updated almost 12 years ago.

Status:
Closed
Target version:
ruby -v:
2.0.0preview1
Backport:
[ruby-core:49619]

Description

system ~/projects/jruby/gist-4110634 $ jirb
irb(main):001:0> $_ = 'foo'
=> "foo"
irb(main):002:0> def blah; p $; end
=> nil
irb(main):003:0> p $

"foo"
=> "foo"
irb(main):004:0> blah
nil
=> nil

Not thread-local.

Updated by headius (Charles Nutter) about 12 years ago

I guess this is a bit confusing, since it does also say it's scope-local. The thread-local part throws me off a bit. Is it thread-local or scope-local?

Here's the example again, this time actually running in 2.0.0.preview1:

system ~/projects/jruby $ irb-2.0.0
irb(main):001:0> $_ = 'foo'
=> "foo"
irb(main):002:0> def blah; p $; end
=> nil
irb(main):003:0> p $

"foo"
=> "foo"
irb(main):004:0> blah
nil
=> nil

Updated by mame (Yusuke Endoh) about 12 years ago

  • Status changed from Open to Assigned
  • Assignee set to mame (Yusuke Endoh)
  • Target version set to 2.0.0

I think that "scope-local" normally implies "thread-local".
If you think it is confusing, I'll delete the comments, unless there is objection.

diff --git a/lib/English.rb b/lib/English.rb
index 4fd53c5..44baf17 100644
--- a/lib/English.rb
+++ b/lib/English.rb
@@ -119,7 +119,7 @@ alias $CHILD_STATUS $?

and $1 to $9 are all derived from

$~. Assigning to $~ changes the values of these

derived variables. This variable is local to the current

-# scope. Thread local.
+# scope.
alias $LAST_MATCH_INFO $~

If set to any value apart from +nil+ or +false+, all pattern matches

@@ -135,21 +135,21 @@ alias $ARGV $*

The string matched by the last successful pattern

match. This variable is local to the current

-# scope. Read only. Thread local.
+# scope. Read only.
alias $MATCH $&

The string preceding the match in the last

successful pattern match. This variable is local to

-# the current scope. Read only. Thread local.
+# the current scope. Read only.
alias $PREMATCH $`

The string following the match in the last

successful pattern match. This variable is local to

-# the current scope. Read only. Thread local.
+# the current scope. Read only.
alias $POSTMATCH $'

The contents of the highest-numbered group matched in the last

successful pattern match. Thus, in "cat" =~ /(c|a)(t|z)/,

$+ will be set to "t". This variable is local to the

-# current scope. Read only. Thread local.
+# current scope. Read only.
alias $LAST_PAREN_MATCH $+

--
Yusuke Endoh

Actions #3

Updated by mame (Yusuke Endoh) almost 12 years ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

This issue was solved with changeset r39010.
Charles, thank you for reporting this issue.
Your contribution to Ruby is greatly appreciated.
May Ruby be with you.


  • lib/English.rb: Remove some confusing words from rdoc. [Bug #7406]
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0