From: nobu@ruby-lang.org
To: ruby-core@ruby-lang.org
Subject: [ruby-core:99840] [Ruby master Feature#17104] Do not freeze interpolated strings when using frozen-string-literal
Date: Wed, 02 Sep 2020 14:15:22 +0000 (UTC) [thread overview]
Message-ID: <redmine.journal-87364.20200902141521.8741@ruby-lang.org> (raw)
In-Reply-To: redmine.issue-17104.20200805200602.8741@ruby-lang.org
Issue #17104 has been updated by nobu (Nobuyoshi Nakada).
https://github.com/nobu/ruby/tree/unfrozen-literal
----------------------------------------
Feature #17104: Do not freeze interpolated strings when using frozen-string-literal
https://bugs.ruby-lang.org/issues/17104#change-87364
* 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/
next prev parent reply other threads:[~2020-09-02 14:15 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-05 20:06 [ruby-core:99485] [Ruby master Misc#17104] Why are interpolated string literals frozen? bughitgithub
2020-08-05 20:25 ` [ruby-core:99487] " merch-redmine
2020-08-05 20:58 ` [ruby-core:99488] " bughitgithub
2020-08-05 21:05 ` [ruby-core:99489] " merch-redmine
2020-08-05 21:10 ` [ruby-core:99490] " eregontp
2020-08-05 21:18 ` [ruby-core:99491] " bughitgithub
2020-08-05 21:26 ` [ruby-core:99492] [Ruby master Feature#17104] Do not freeze interpolated strings when using frozen-string-literal merch-redmine
2020-08-06 1:37 ` [ruby-core:99493] " daniel
2020-08-06 9:23 ` [ruby-core:99496] " jean.boussier
2020-08-06 10:12 ` [ruby-core:99497] " eregontp
2020-08-06 11:10 ` [ruby-core:99501] " jean.boussier
2020-08-10 18:51 ` [ruby-core:99546] " bughitgithub
2020-08-11 6:22 ` [ruby-core:99551] " duerst
2020-08-11 15:57 ` [ruby-core:99560] " bughitgithub
2020-08-26 7:43 ` [ruby-core:99699] " akr
2020-08-31 8:50 ` [ruby-core:99793] " matz
2020-08-31 19:28 ` [ruby-core:99802] " eregontp
2020-09-01 15:39 ` [ruby-core:99817] " mame
2020-09-01 18:18 ` [ruby-core:99822] " eregontp
2020-09-02 14:15 ` nobu [this message]
2020-09-03 0:29 ` [ruby-core:99858] " ko1
2020-09-03 14:26 ` [ruby-core:99877] " eregontp
2020-09-15 19:35 ` [ruby-core:100015] " eregontp
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.ruby-lang.org/en/community/mailing-lists/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=redmine.journal-87364.20200902141521.8741@ruby-lang.org \
--to=ruby-core@ruby-lang.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).