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

* [ruby-core:100505] [Ruby master Bug#17268] special global variables which can be accessed from ractors
  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 ` daniel
  2020-10-22 19:31 ` [ruby-core:100509] " eregontp
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: daniel @ 2020-10-22 14:56 UTC (permalink / raw)
  To: ruby-core

Issue #17268 has been updated by Dan0042 (Daniel DeLorme).


Why can't ractors access global variables? Shouldn't it be like constants, where a frozen/shareable object can be accessed?
```ruby
$x = [1,2,3]
Ractor.new{ $x }.take  # I understand that this can't work
$x = true
Ractor.new{ $x }.take  # but why is this not ok?
```

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

* 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/

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

* [ruby-core:100509] [Ruby master Bug#17268] special global variables which can be accessed from ractors
  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 ` eregontp
  2020-10-22 21:18 ` [ruby-core:100510] " daniel
  2020-10-26 16:36 ` [ruby-core:100583] " ko1
  3 siblings, 0 replies; 5+ messages in thread
From: eregontp @ 2020-10-22 19:31 UTC (permalink / raw)
  To: ruby-core

Issue #17268 has been updated by Eregon (Benoit Daloze).


I think this issue is mostly about "special" global variables, not so much about "regular" global variables.

I wonder if "regular" global variables should be Ractor-local, or behave like constants.
Since most of the above became Ractor-local (instead of per-Process before) or a narrower scope, I think Ractor-local would make most sense.
The only special variables that are still process-local are read-only, which means it's the same as if they were Ractor-local read-only.

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

* 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/

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

* [ruby-core:100510] [Ruby master Bug#17268] special global variables which can be accessed from ractors
  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 ` daniel
  2020-10-26 16:36 ` [ruby-core:100583] " ko1
  3 siblings, 0 replies; 5+ messages in thread
From: daniel @ 2020-10-22 21:18 UTC (permalink / raw)
  To: ruby-core

Issue #17268 has been updated by Dan0042 (Daniel DeLorme).


Eregon (Benoit Daloze) wrote in #note-4:
> I wonder if "regular" global variables should be Ractor-local, or behave like constants.

I wouldn't mind either way. Although if Ractor-local I would hope they are derived from created ractor, like $DEBUG and $VERBOSE.

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

* 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/

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

* [ruby-core:100583] [Ruby master Bug#17268] special global variables which can be accessed from ractors
  2020-10-20  1:47 [ruby-core:100439] [Ruby master Bug#17268] special global variables which can be accessed from ractors ko1
                   ` (2 preceding siblings ...)
  2020-10-22 21:18 ` [ruby-core:100510] " daniel
@ 2020-10-26 16:36 ` ko1
  3 siblings, 0 replies; 5+ messages in thread
From: ko1 @ 2020-10-26 16:36 UTC (permalink / raw)
  To: ruby-core

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/

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