From: ko1@atdot.net
To: ruby-core@ruby-lang.org
Subject: [ruby-core:100583] [Ruby master Bug#17268] special global variables which can be accessed from ractors
Date: Mon, 26 Oct 2020 16:36:12 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-88215.20201026163612.17@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17268.20201020014746.17@ruby-lang.org
Issue #17268 has been updated by ko1 (Koichi Sasada).
The proposal is accepted.
> I wonder if "regular" global variables should be Ractor-local, or behave like constants.
This is rejected at first by Matz (my original proposal is making all $gvars are ractor-local), to avoid confusion.
----------------------------------------
Bug #17268: special global variables which can be accessed from ractors
https://bugs.ruby-lang.org/issues/17268#change-88215
* Author: ko1 (Koichi Sasada)
* Status: Closed
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
Ractors can't access global variables, but some special global variables should be accessed.
There are several types.
## Proposal
(1) Read-only global variables
```ruby
# process-local (readonly): other commandline parameters
'$-p' => $-p,
'$-l' => $-l,
'$-a' => $-a,
# process-local (readonly): getpid
'$$' => $$,
```
(2) scope local variables
```ruby
# thread local: process result
'$?' => $?,
# scope local: match
'$~' => $~.inspect,
'$&' => $&,
'$`' => $`,
'$\'' => $',
'$+' => $+,
'$1' => $1,
# scope local: last line
'$_' => $_,
# scope local: last backtrace
'$@' => $@,
'$!' => $!,
```
(3) Ractor local variables
```ruby
# ractor-local (derived from created ractor): debug
'$DEBUG' => $DEBUG,
'$-d' => $-d,
# ractor-local (derived from created ractor): verbose
'$VERBOSE' => $VERBOSE,
'$-w' => $-w,
'$-W' => $-W,
'$-v' => $-v,
# ractor local: stdin, out, err
'$stdin' => $stdin.inspect,
'$stdout' => $stdout.inspect,
'$stderr' => $stderr.inspect,
```
Implementation: https://github.com/ruby/ruby/pull/3670
I'll merge it soon.
## Discussion
* only accessible from main ractor?
* `$0`:
* ARGV, ARGF, `$.`
* only accessible from main ractor because they will be obsolete
* `$, $/ $; $\`
* So difficult: `$" / $LOADED_FEATURES` and `$: / $LOAD_PATH`
--
https://bugs.ruby-lang.org/
prev parent reply other threads:[~2020-10-26 16:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-20 1:47 [ruby-core:100439] [Ruby master Bug#17268] special global variables which can be accessed from ractors ko1
2020-10-22 14:56 ` [ruby-core:100505] " daniel
2020-10-22 19:31 ` [ruby-core:100509] " eregontp
2020-10-22 21:18 ` [ruby-core:100510] " daniel
2020-10-26 16:36 ` ko1 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-88215.20201026163612.17@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).