ruby-core@ruby-lang.org archive (unofficial mirror)
 help / color / mirror / Atom feed
* [ruby-core:115000] [Ruby master Feature#16294] Make MatchData frozen and forbid MatchData.allocate
       [not found] <redmine.issue-16294.20191105125925.772@ruby-lang.org>
@ 2023-10-11  7:55 ` nobu (Nobuyoshi Nakada) via ruby-core
  2023-10-11  8:58 ` [ruby-core:115002] " Eregon (Benoit Daloze) via ruby-core
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2023-10-11  7:55 UTC (permalink / raw
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #16294 has been updated by nobu (Nobuyoshi Nakada).


I've forgot this for years, and just happened to discover this branch.
https://github.com/ruby/ruby/pull/8624

----------------------------------------
Feature #16294: Make MatchData frozen and forbid MatchData.allocate
https://bugs.ruby-lang.org/issues/16294#change-104868

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
----------------------------------------
Currently, `MatchData.allocate` is allowed, but almost every MatchData method called on it `raise TypeError, 'uninitialized Match'`.

I think MatchData should be frozen, none of its internal fields are mutable and I don't see any use case for storing instance variables on it.
Once frozen, we can implement MatchData#dup and #clone as just `return self`, and we don't need to check for the uninitialized case.
And Marshal can have special treatment to create an initialized MatchData directly.

My main motivation is looking at the code in TruffleRuby required to implement `MatchData.allocate` and check if it's initialized in so many places:
https://github.com/oracle/truffleruby/pull/1792/files

Thoughts? Anyone against?
cc @alanwu




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:115002] [Ruby master Feature#16294] Make MatchData frozen and forbid MatchData.allocate
       [not found] <redmine.issue-16294.20191105125925.772@ruby-lang.org>
  2023-10-11  7:55 ` [ruby-core:115000] [Ruby master Feature#16294] Make MatchData frozen and forbid MatchData.allocate nobu (Nobuyoshi Nakada) via ruby-core
@ 2023-10-11  8:58 ` Eregon (Benoit Daloze) via ruby-core
  2023-10-14  2:30 ` [ruby-core:115051] " nobu (Nobuyoshi Nakada) via ruby-core
  2023-10-14 10:03 ` [ruby-core:115053] " Eregon (Benoit Daloze) via ruby-core
  3 siblings, 0 replies; 4+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2023-10-11  8:58 UTC (permalink / raw
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

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


Looks good, I think we should merge it.
(and this is already the case on TruffleRuby)

----------------------------------------
Feature #16294: Make MatchData frozen and forbid MatchData.allocate
https://bugs.ruby-lang.org/issues/16294#change-104870

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
----------------------------------------
Currently, `MatchData.allocate` is allowed, but almost every MatchData method called on it `raise TypeError, 'uninitialized Match'`.

I think MatchData should be frozen, none of its internal fields are mutable and I don't see any use case for storing instance variables on it.
Once frozen, we can implement MatchData#dup and #clone as just `return self`, and we don't need to check for the uninitialized case.
And Marshal can have special treatment to create an initialized MatchData directly.

My main motivation is looking at the code in TruffleRuby required to implement `MatchData.allocate` and check if it's initialized in so many places:
https://github.com/oracle/truffleruby/pull/1792/files

Thoughts? Anyone against?
cc @alanwu




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:115051] [Ruby master Feature#16294] Make MatchData frozen and forbid MatchData.allocate
       [not found] <redmine.issue-16294.20191105125925.772@ruby-lang.org>
  2023-10-11  7:55 ` [ruby-core:115000] [Ruby master Feature#16294] Make MatchData frozen and forbid MatchData.allocate nobu (Nobuyoshi Nakada) via ruby-core
  2023-10-11  8:58 ` [ruby-core:115002] " Eregon (Benoit Daloze) via ruby-core
@ 2023-10-14  2:30 ` nobu (Nobuyoshi Nakada) via ruby-core
  2023-10-14 10:03 ` [ruby-core:115053] " Eregon (Benoit Daloze) via ruby-core
  3 siblings, 0 replies; 4+ messages in thread
From: nobu (Nobuyoshi Nakada) via ruby-core @ 2023-10-14  2:30 UTC (permalink / raw
  To: ruby-core; +Cc: nobu (Nobuyoshi Nakada)

Issue #16294 has been updated by nobu (Nobuyoshi Nakada).


At the latest dev-meeting, there was a suggestion that whereas `MatchData` cannot be dumped, `Regexp.allocate` might be used by serializer libraries.

----------------------------------------
Feature #16294: Make MatchData frozen and forbid MatchData.allocate
https://bugs.ruby-lang.org/issues/16294#change-104925

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
----------------------------------------
Currently, `MatchData.allocate` is allowed, but almost every MatchData method called on it `raise TypeError, 'uninitialized Match'`.

I think MatchData should be frozen, none of its internal fields are mutable and I don't see any use case for storing instance variables on it.
Once frozen, we can implement MatchData#dup and #clone as just `return self`, and we don't need to check for the uninitialized case.
And Marshal can have special treatment to create an initialized MatchData directly.

My main motivation is looking at the code in TruffleRuby required to implement `MatchData.allocate` and check if it's initialized in so many places:
https://github.com/oracle/truffleruby/pull/1792/files

Thoughts? Anyone against?
cc @alanwu




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

* [ruby-core:115053] [Ruby master Feature#16294] Make MatchData frozen and forbid MatchData.allocate
       [not found] <redmine.issue-16294.20191105125925.772@ruby-lang.org>
                   ` (2 preceding siblings ...)
  2023-10-14  2:30 ` [ruby-core:115051] " nobu (Nobuyoshi Nakada) via ruby-core
@ 2023-10-14 10:03 ` Eregon (Benoit Daloze) via ruby-core
  3 siblings, 0 replies; 4+ messages in thread
From: Eregon (Benoit Daloze) via ruby-core @ 2023-10-14 10:03 UTC (permalink / raw
  To: ruby-core; +Cc: Eregon (Benoit Daloze)

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


nobu (Nobuyoshi Nakada) wrote in #note-8:
> At the latest dev-meeting, there was a suggestion that whereas `MatchData` cannot be dumped, `Regexp.allocate` might be used by serializer libraries.

That does not seem used in practice.
TruffleRuby already does not define `Regexp.allocate`, and there seems to be no compatibility issue with that except some specs.
`Regexp.new` (or `eval`) is good enough for deserializing regexps.

----------------------------------------
Feature #16294: Make MatchData frozen and forbid MatchData.allocate
https://bugs.ruby-lang.org/issues/16294#change-104928

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
----------------------------------------
Currently, `MatchData.allocate` is allowed, but almost every MatchData method called on it `raise TypeError, 'uninitialized Match'`.

I think MatchData should be frozen, none of its internal fields are mutable and I don't see any use case for storing instance variables on it.
Once frozen, we can implement MatchData#dup and #clone as just `return self`, and we don't need to check for the uninitialized case.
And Marshal can have special treatment to create an initialized MatchData directly.

My main motivation is looking at the code in TruffleRuby required to implement `MatchData.allocate` and check if it's initialized in so many places:
https://github.com/oracle/truffleruby/pull/1792/files

Thoughts? Anyone against?
cc @alanwu




-- 
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/postorius/lists/ruby-core.ml.ruby-lang.org/

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

end of thread, other threads:[~2023-10-14 10:03 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <redmine.issue-16294.20191105125925.772@ruby-lang.org>
2023-10-11  7:55 ` [ruby-core:115000] [Ruby master Feature#16294] Make MatchData frozen and forbid MatchData.allocate nobu (Nobuyoshi Nakada) via ruby-core
2023-10-11  8:58 ` [ruby-core:115002] " Eregon (Benoit Daloze) via ruby-core
2023-10-14  2:30 ` [ruby-core:115051] " nobu (Nobuyoshi Nakada) via ruby-core
2023-10-14 10:03 ` [ruby-core:115053] " Eregon (Benoit Daloze) 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 read-only IMAP folder(s) and NNTP newsgroup(s).