ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects
@ 2020-10-09  7:42 ko1
  2020-10-20  6:25 ` [ruby-core:100443] " ko1
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: ko1 @ 2020-10-09  7:42 UTC (permalink / raw)
  To: ruby-core

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

----------------------------------------
Feature #17256: Freeze all Regexp objects
https://bugs.ruby-lang.org/issues/17256

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
To share Regexp objects between ractors, these regexps should be frozen.

Now, Matz proposed make all Regexp objects frozen.

On https://bugs.ruby-lang.org/issues/16377#note-7
> For the record: Regexp.new should continue to return unfrozen Regexp instance.

so I'm afraid it is good way or not.
But can we have your comment on it.

If no comments, I'll try to freeze them , before Ruby 3.0 preview 2.

BTW, I believe `/#{expr}/o` should be frozen because this expression only returns one Regexp object.




-- 
https://bugs.ruby-lang.org/

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

* [ruby-core:100443] [Ruby master Feature#17256] Freeze all Regexp objects
  2020-10-09  7:42 [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects ko1
@ 2020-10-20  6:25 ` ko1
  2020-10-20 20:47 ` [ruby-core:100455] " eregontp
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: ko1 @ 2020-10-20  6:25 UTC (permalink / raw)
  To: ruby-core

Issue #17256 has been updated by ko1 (Koichi Sasada).


I tried it and several errors are observed on tests.
It is possible that people want to tweak Regexp objects (unlike Range objects).

How about to freeze literals includes `/#{expr}/`?
https://github.com/ruby/ruby/pull/3676
It is easy to fix by `.dup` method.

----------------------------------------
Feature #17256: Freeze all Regexp objects
https://bugs.ruby-lang.org/issues/17256#change-88058

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
To be shared between ractors, Regexp objects should be frozen.

Now, Matz has proposed to make all Regexp objects frozen.

Ten months ago, there was a note https://bugs.ruby-lang.org/issues/16377#note-7 :

> For the record: Regexp.new should continue to return unfrozen Regexp instance.

So I'm not sure whether it is a good way or not.

Could you give me your comment on it?

If no comments are given, I'll try to freeze them before Ruby 3.0 preview 2.

BTW, I believe `/#{expr}/o` should be frozen because this expression only returns one Regexp object.




-- 
https://bugs.ruby-lang.org/

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

* [ruby-core:100455] [Ruby master Feature#17256] Freeze all Regexp objects
  2020-10-09  7:42 [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects ko1
  2020-10-20  6:25 ` [ruby-core:100443] " ko1
@ 2020-10-20 20:47 ` eregontp
  2020-10-21  2:57 ` [ruby-core:100462] " daniel
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: eregontp @ 2020-10-20 20:47 UTC (permalink / raw)
  To: ruby-core

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


@ko1 Could you show the errors from the tests?
Some tests are there just for regression or corner cases, I think actual user code matters far more than tests when it comes to backward-incompatible changes.
It seems odd to store anything on a Regexp.

----------------------------------------
Feature #17256: Freeze all Regexp objects
https://bugs.ruby-lang.org/issues/17256#change-88074

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
To be shared between ractors, Regexp objects should be frozen.

Now, Matz has proposed to make all Regexp objects frozen.

Ten months ago, there was a note https://bugs.ruby-lang.org/issues/16377#note-7 :

> For the record: Regexp.new should continue to return unfrozen Regexp instance.

So I'm not sure whether it is a good way or not.

Could you give me your comment on it?

If no comments are given, I'll try to freeze them before Ruby 3.0 preview 2.

BTW, I believe `/#{expr}/o` should be frozen because this expression only returns one Regexp object.




-- 
https://bugs.ruby-lang.org/

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

* [ruby-core:100462] [Ruby master Feature#17256] Freeze all Regexp objects
  2020-10-09  7:42 [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects ko1
  2020-10-20  6:25 ` [ruby-core:100443] " ko1
  2020-10-20 20:47 ` [ruby-core:100455] " eregontp
@ 2020-10-21  2:57 ` daniel
  2020-10-21  4:08 ` [ruby-core:100463] " marcandre-ruby-core
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: daniel @ 2020-10-21  2:57 UTC (permalink / raw)
  To: ruby-core

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


Given that string literals with interpolation were recently unfrozen, it would appear slightly inconsistent to freeze regexp literals with interpolation.
`/#{str}/` is equivalent to `Regexp.new(str)` so I would find it a bit weird if they had a different behavior w/r freezing. It would make more sense to say that _all_ new regexps (including `Regexp.new` and `Regexp.compile`) are frozen. That way all constants such as `UNSAFE = Regexp.new("[^#{SAFE_STRING}]", false)` would be automatically ractor-safe.

And if someone really needs to modify a regexp maybe they can use `dup`?
`rx = Regexp.new(str).dup.extend(PrintWhenMatch)`

----------------------------------------
Feature #17256: Freeze all Regexp objects
https://bugs.ruby-lang.org/issues/17256#change-88081

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
To be shared between ractors, Regexp objects should be frozen.

Now, Matz has proposed to make all Regexp objects frozen.

Ten months ago, there was a note https://bugs.ruby-lang.org/issues/16377#note-7 :

> For the record: Regexp.new should continue to return unfrozen Regexp instance.

So I'm not sure whether it is a good way or not.

Could you give me your comment on it?

If no comments are given, I'll try to freeze them before Ruby 3.0 preview 2.

BTW, I believe `/#{expr}/o` should be frozen because this expression only returns one Regexp object.




-- 
https://bugs.ruby-lang.org/

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

* [ruby-core:100463] [Ruby master Feature#17256] Freeze all Regexp objects
  2020-10-09  7:42 [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects ko1
                   ` (2 preceding siblings ...)
  2020-10-21  2:57 ` [ruby-core:100462] " daniel
@ 2020-10-21  4:08 ` marcandre-ruby-core
  2020-10-26 16:40 ` [ruby-core:100586] " ko1
  2020-10-29 16:05 ` [ruby-core:100645] " ko1
  5 siblings, 0 replies; 7+ messages in thread
From: marcandre-ruby-core @ 2020-10-21  4:08 UTC (permalink / raw)
  To: ruby-core

Issue #17256 has been updated by marcandre (Marc-Andre Lafortune).


Dan0042 (Daniel DeLorme) wrote in #note-6:
> Given that string literals with interpolation were recently unfrozen, it would appear slightly inconsistent to freeze regexp literals with interpolation.

The difference is that there are many methods and usecases to mutate a String, and none that we know of to mutate a Regexp.

----------------------------------------
Feature #17256: Freeze all Regexp objects
https://bugs.ruby-lang.org/issues/17256#change-88082

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
To be shared between ractors, Regexp objects should be frozen.

Now, Matz has proposed to make all Regexp objects frozen.

Ten months ago, there was a note https://bugs.ruby-lang.org/issues/16377#note-7 :

> For the record: Regexp.new should continue to return unfrozen Regexp instance.

So I'm not sure whether it is a good way or not.

Could you give me your comment on it?

If no comments are given, I'll try to freeze them before Ruby 3.0 preview 2.

BTW, I believe `/#{expr}/o` should be frozen because this expression only returns one Regexp object.




-- 
https://bugs.ruby-lang.org/

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

* [ruby-core:100586] [Ruby master Feature#17256] Freeze all Regexp objects
  2020-10-09  7:42 [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects ko1
                   ` (3 preceding siblings ...)
  2020-10-21  4:08 ` [ruby-core:100463] " marcandre-ruby-core
@ 2020-10-26 16:40 ` ko1
  2020-10-29 16:05 ` [ruby-core:100645] " ko1
  5 siblings, 0 replies; 7+ messages in thread
From: ko1 @ 2020-10-26 16:40 UTC (permalink / raw)
  To: ruby-core

Issue #17256 has been updated by ko1 (Koichi Sasada).


> ko1 (Koichi Sasada) Could you show the errors from the tests?

Sorry I lost the patch.

Anyway, at last dev-meeting, freezing all Regexp *literals* including dynamically created objects are accepted.
I don't have objection to freeze all regexp objects, but we need to observe the incompatibilities in existing code and I have no time to handle them. Try on 3.1 if someone can try?


----------------------------------------
Feature #17256: Freeze all Regexp objects
https://bugs.ruby-lang.org/issues/17256#change-88218

* Author: ko1 (Koichi Sasada)
* Status: Open
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
To be shared between ractors, Regexp objects should be frozen.

Now, Matz has proposed to make all Regexp objects frozen.

Ten months ago, there was a note https://bugs.ruby-lang.org/issues/16377#note-7 :

> For the record: Regexp.new should continue to return unfrozen Regexp instance.

So I'm not sure whether it is a good way or not.

Could you give me your comment on it?

If no comments are given, I'll try to freeze them before Ruby 3.0 preview 2.

BTW, I believe `/#{expr}/o` should be frozen because this expression only returns one Regexp object.




-- 
https://bugs.ruby-lang.org/

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

* [ruby-core:100645] [Ruby master Feature#17256] Freeze all Regexp objects
  2020-10-09  7:42 [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects ko1
                   ` (4 preceding siblings ...)
  2020-10-26 16:40 ` [ruby-core:100586] " ko1
@ 2020-10-29 16:05 ` ko1
  5 siblings, 0 replies; 7+ messages in thread
From: ko1 @ 2020-10-29 16:05 UTC (permalink / raw)
  To: ruby-core

Issue #17256 has been updated by ko1 (Koichi Sasada).

Status changed from Open to Closed

7ad56fd87b35abf4933e0146761df91e9ec9890a 

----------------------------------------
Feature #17256: Freeze all Regexp objects
https://bugs.ruby-lang.org/issues/17256#change-88283

* Author: ko1 (Koichi Sasada)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
To be shared between ractors, Regexp objects should be frozen.

Now, Matz has proposed to make all Regexp objects frozen.

Ten months ago, there was a note https://bugs.ruby-lang.org/issues/16377#note-7 :

> For the record: Regexp.new should continue to return unfrozen Regexp instance.

So I'm not sure whether it is a good way or not.

Could you give me your comment on it?

If no comments are given, I'll try to freeze them before Ruby 3.0 preview 2.

BTW, I believe `/#{expr}/o` should be frozen because this expression only returns one Regexp object.




-- 
https://bugs.ruby-lang.org/

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

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

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-09  7:42 [ruby-core:100345] [Ruby master Feature#17256] Freeze all Regexp objects ko1
2020-10-20  6:25 ` [ruby-core:100443] " ko1
2020-10-20 20:47 ` [ruby-core:100455] " eregontp
2020-10-21  2:57 ` [ruby-core:100462] " daniel
2020-10-21  4:08 ` [ruby-core:100463] " marcandre-ruby-core
2020-10-26 16:40 ` [ruby-core:100586] " ko1
2020-10-29 16:05 ` [ruby-core:100645] " 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).