Forum: Ruby-core [ruby-trunk - Bug #7406][Open] English.rb says that $_ is thread-local, but it is frame-local

Posted by Charles Nutter (headius)
on 2012-11-19 23:29
(Received via mailing list)
Issue #7406 has been reported by headius (Charles Nutter).

----------------------------------------
Bug #7406: English.rb says that $_ is thread-local, but it is 
frame-local
https://bugs.ruby-lang.org/issues/7406

Author: headius (Charles Nutter)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 2.0.0preview1


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.
Posted by Charles Nutter (headius)
on 2012-11-19 23:32
(Received via mailing list)
Issue #7406 has been updated by headius (Charles Nutter).


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


----------------------------------------
Bug #7406: English.rb says that $_ is thread-local, but it is 
frame-local
https://bugs.ruby-lang.org/issues/7406#change-33134

Author: headius (Charles Nutter)
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
ruby -v: 2.0.0preview1


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.
Posted by mame (Yusuke Endoh) (Guest)
on 2012-11-24 10:17
(Received via mailing list)
Issue #7406 has been updated by mame (Yusuke Endoh).

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 <tt>$1</tt> to <tt>$9</tt> are all derived from
 # <tt>$~</tt>. Assigning to <tt>$~</tt> 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 <tt>"cat" =~ /(c|a)(t|z)/</tt>,
 # <tt>$+</tt> 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 <mame@tsg.ne.jp>
----------------------------------------
Bug #7406: English.rb says that $_ is thread-local, but it is 
frame-local
https://bugs.ruby-lang.org/issues/7406#change-33805

Author: headius (Charles Nutter)
Status: Assigned
Priority: Normal
Assignee: mame (Yusuke Endoh)
Category:
Target version: 2.0.0
ruby -v: 2.0.0preview1


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.
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.