From: bughitgithub@... Date: 2020-08-05T21:18:00+00:00 Subject: [ruby-core:99491] [Ruby master Misc#17104] Why are interpolated string literals frozen? Issue #17104 has been updated by bughit (bug hit). Can't we just treat this as I feature request? The reasons are, it will reduce allocations, be more logical, less surprising and produce simpler code (when a mutable string is needed and you don't want extra allocations) ---------------------------------------- Misc #17104: Why are interpolated string literals frozen? https://bugs.ruby-lang.org/issues/17104#change-86947 * Author: bughit (bug hit) * Status: Closed * Priority: Normal ---------------------------------------- ```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' ``` Isn't the point of frozen literals to avoid needless allocations? But interpolated strings are allocated each time, so freezing appears pointless. -- https://bugs.ruby-lang.org/ Unsubscribe: