Issue #11473 has been updated by headius (Charles Nutter).


I regret missing this "final" decision, but I believe we should reconsider.

> I am sure introducing this could cause HUGE compatibility issue

Truly? We have had the syntactic hacks (.freeze etc), frozen-string-literal pragma, and the command-line global flag for many years now. A very large corpus of existing code already opts into frozen string literals today, including most of Rails and its dependencies. RuboCop (the most popular linter by far) and other tools have been recommending users include the frozen-string-literal pragma as well.

And I have a path forward that would easily address any breakage: we add a `mutable-string-literal` pragma.

1. Ruby 2.7 should include a `mutable-string-literal` pragma that allows users to opt into mutable strings on a file-by-file basis. It would be ignored when the `frozen-string-literal` feature is disabled.
2. We all start testing our code on Ruby 2.7 with `--enable:frozen-string-literal` and fix code to opt into mutable strings using either `"".dup" or the file-wide `mutable-string-literal` pragma.
3. By the time Ruby 3.0 is released in late 2020, all we should need to do is enable `frozen-string-literal` by default.

I really don't think this migration path would be difficult, and I suspect that the vast majority of Ruby code out there would work out of the box or require only minor changes to be compatible.

----------------------------------------
Feature #11473: Immutable String literal in Ruby 3
https://bugs.ruby-lang.org/issues/11473#change-81563

* Author: ko1 (Koichi Sasada)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
* Target version: 
----------------------------------------
Matz said "All String literals are immutable (frozen) on Ruby 3".

This ticket is place holder to discuss about that.




-- 
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>