ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:100439] [Ruby master Bug#17268] special global variables which can be accessed from ractors
@ 2020-10-20  1:47 ko1
  2020-10-22 14:56 ` [ruby-core:100505] " daniel
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: ko1 @ 2020-10-20  1:47 UTC (permalink / raw)
  To: ruby-core

Issue #17268 has been reported by ko1 (Koichi Sasada).

----------------------------------------
Bug #17268: special global variables which can be accessed from ractors
https://bugs.ruby-lang.org/issues/17268

* Author: ko1 (Koichi Sasada)
* Status: Open
* 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: 
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/

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-10-26 16:36 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 ` [ruby-core:100583] " ko1

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).