From: "colindkelley (Colin Kelley)" Date: 2013-12-31T01:28:09+09:00 Subject: [ruby-core:59410] [ruby-trunk - Feature #9278] Magic comment "immutable: string" makes "literal".freeze the default for that file Issue #9278 has been updated by colindkelley (Colin Kelley). > Perhaps if you show concrete gains in a large code-base like rails the case will be more compelling. Working on it! First to see how many tests actually fail from trying to mutate string literals, then to get some general performance numbers. ---------------------------------------- Feature #9278: Magic comment "immutable: string" makes "literal".freeze the default for that file https://bugs.ruby-lang.org/issues/9278#change-43974 Author: colindkelley (Colin Kelley) Status: Open Priority: Normal Assignee: Category: core Target version: 2.1.0 Building on https://bugs.ruby-lang.org/issues/9042, this pull request adds the magic comment # -*- immutable: string -*- that implies .freeze on every string literal in the file. To get a mutable string in a file that starts with the magic comment, use String.new or ''.dup. Here is a corresponding github pull request: https://github.com/ruby/ruby/pull/487 For more details, background, and rationale, please see this blog post: http://development.invoca.com/magic-comment-immutable-string-makes-ruby-2-1s-literal-freeze-optimization-the-default/ -- http://bugs.ruby-lang.org/