[#122973] [PATCH] Add Gem.default_install — Felipe Contreras via ruby-core <ruby-core@...>
We need a way to enable user installs by default so that tools like
3 messages
2025/08/17
[ruby-core:122909] [Ruby Bug#21529] Deprecate the /o modifier and warn against using it
From:
"luke-gru (Luke Gruber) via ruby-core" <ruby-core@...>
Date:
2025-08-04 15:40:29 UTC
List:
ruby-core #122909
Issue #21529 has been updated by luke-gru (Luke Gruber).
This is also racy with ractors, and with multiple ractors is not guaranteed to run only once.
----------------------------------------
Bug #21529: Deprecate the /o modifier and warn against using it
https://bugs.ruby-lang.org/issues/21529#change-114213
* Author: jpcamara (JP Camara)
* Status: Open
* Backport: 3.2: UNKNOWN, 3.3: UNKNOWN, 3.4: UNKNOWN
----------------------------------------
I recently ran into a bug in some code because it was using the /o modifier as an optimization, not realizing it created a permanent, immutable value after the first time it gets evaluated. I dug into how the modifier works in CRuby and the history of it here: https://jpcamara.com/2025/08/02/the-o-in-ruby-regex.html.
The feature seems like a total footgun with almost no upside. If I run a benchmark between a local regex, and a regex cached by /o, there is no real difference.
```rb
require "benchmark"
def letters
"A-Za-z"
end
words = %w[the quick brown fox jumped over the lazy dog]
Benchmark.bm do |bm|
bm.report("without /o:") do
regex = /\A[A-Za-z]+\z/
words.each do |word|
word.match(regex)
end
end
bm.report("with /o: ") do
words.each do |word|
word.match(/\A[#{letters}]+\z/o)
end
end
end
```
Most of the time I found that "without /o" actually came out ahead.
```
user system total real
without /o: 0.000019 0.000003 0.000022 ( 0.000014)
with /o: 0.000020 0.000001 0.000021 ( 0.000020)
```
I'd like to deprecate the feature and update the docs to warn against using it. I'd be happy to submit a PR doing that.
Thanks!
--
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/