Project

General

Profile

Actions

Feature #9278

closed

Magic comment "immutable: string" makes "literal".freeze the default for that file

Added by colindkelley (Colin Kelley) over 10 years ago. Updated about 6 years ago.

Status:
Closed
Assignee:
-
Target version:
[ruby-core:59260]

Description

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/

Related issues 1 (0 open1 closed)

Is duplicate of Ruby master - Feature #8976: file-scope freeze_string directiveClosedmatz (Yukihiro Matsumoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0