Issue #16294 has been updated by mame (Yusuke Endoh).


I'm not against the proposal itself, but is it okay to introduce an incompatibility at this time?  cc: @naruse

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

* Author: Eregon (Benoit Daloze)
* Status: Closed
* Priority: Normal
* Assignee: 
* Target version: 
----------------------------------------
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/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>