From: eregontp@... Date: 2020-09-03T14:26:47+00:00 Subject: [ruby-core:99877] [Ruby master Feature#17104] Do not freeze interpolated strings when using frozen-string-literal Issue #17104 has been updated by Eregon (Benoit Daloze). ko1 (Koichi Sasada) wrote in #note-21: > I found that freezing interpolated strings are help for Ractor programming with constants. Right, anything deeply frozen is helpful for Ractor. But interpolated Strings are probably not that common. I see an interpolated String much like an Array literals, and those are not frozen without an explicit `.freeze`. ---------------------------------------- Feature #17104: Do not freeze interpolated strings when using frozen-string-literal https://bugs.ruby-lang.org/issues/17104#change-87404 * Author: bughit (bug hit) * Status: Open * Priority: Normal * Assignee: Eregon (Benoit Daloze) ---------------------------------------- I think the point of frozen string literals is to avoid needless allocations. Interpolated strings are allocated each time, so freezing them appears pointless. ```rb #frozen_string_literal: true def foo(str) "#{str}" end fr1 = 'a' fr2 = 'a' fr1_1 = foo(fr1) fr2_1 = foo(fr2) puts fr1.__id__, fr2.__id__, fr1_1.__id__, fr2_1.__id__ puts fr1_1 << 'b' ``` -- 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>