* [ruby-core:120862] [Ruby master Feature#21109] Want to clarify how $/ is handled in Ractor
@ 2025-02-02 13:18 wanabe (_ wanabe) via ruby-core
0 siblings, 0 replies; only message in thread
From: wanabe (_ wanabe) via ruby-core @ 2025-02-02 13:18 UTC (permalink / raw)
To: ruby-core; +Cc: wanabe (_ wanabe)
Issue #21109 has been reported by wanabe (_ wanabe).
----------------------------------------
Feature #21109: Want to clarify how $/ is handled in Ractor
https://bugs.ruby-lang.org/issues/21109
* Author: wanabe (_ wanabe)
* Status: Open
----------------------------------------
I am often in trouble because `$/` is inaccessible in Ractor.
For example, `IO#readline` can't be called from non-main Ractor.
```
$ echo "foo"|ruby -e 'Ractor.new do p $stdin.readline end.take'
-e:1: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
#<Thread:0x00007efbf5ab4f58 run> terminated with exception (report_on_exception is true):
<internal:io>:133:in 'IO#readline': can not access global variables $/ from non-main Ractors (Ractor::IsolationError)
from -e:1:in 'block in <main>'
<internal:ractor>:711:in 'Ractor#take': thrown by remote Ractor. (Ractor::RemoteError)
from -e:1:in '<main>'
<internal:io>:133:in 'IO#readline': can not access global variables $/ from non-main Ractors (Ractor::IsolationError)
from -e:1:in 'block in <main>'
```
But when I use `Kernel.#readline` in Ractor, the behavior is as same as main Ractor.
This behavior changes depending on whether accessing the global variable `$/` in ruby or the internal `rb_rs` in C.
```
$ echo "foo"|ruby -e '$/ = "o"; Ractor.new do p readline end.take'
-e:1: warning: Ractor is experimental, and the behavior may change in future versions of Ruby! Also there are many implementation issues.
"fo"
```
I think it would be better if the behavior is unified and easy to understand.
It would be ideal if it is possible to read and write from Ractor, but even if not, it would be nice if it is at least unified to reduce confusion.
--
https://bugs.ruby-lang.org/
______________________________________________
ruby-core mailing list -- ruby-core@ml.ruby-lang.org
To unsubscribe send an email to ruby-core-leave@ml.ruby-lang.org
ruby-core info -- https://ml.ruby-lang.org/mailman3/lists/ruby-core.ml.ruby-lang.org/
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-02-02 13:18 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-02-02 13:18 [ruby-core:120862] [Ruby master Feature#21109] Want to clarify how $/ is handled in Ractor wanabe (_ wanabe) via ruby-core
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 NNTP newsgroup(s).