Issue #9043 has been updated by charliesome (Charlie Somerville).


I feel really negatively about optimizing only String#f and not String#freeze. You could make the argument that it's backwards compatible, but in reality it means every bit of code that wants to use this optimization needs to monkey patch its own String#f.

Otherwise I support adding String#f as an alias for String#freeze and removing f-suffix syntax.
----------------------------------------
Feature #9043: Add String#f method as shortcut for #freeze
https://bugs.ruby-lang.org/issues/9043#change-42553

Author: headius (Charles Nutter)
Status: Open
Priority: Normal
Assignee: 
Category: core
Target version: current: 2.1.0


We have String#b to create a binary-encoded String, and we have the "f" suffix (going away, hopefully) and the "literal".freeze optimization (#8992). I think it would be reasonable to add String#f as a shorter method for producing a frozen string.

If String#f is added the "literal".freeze optimization could be dropped in favor of "literal".f. This would provide something very close to the original "literal"f syntax but in a backward-compatibility-friendly way (class String; alias f freeze; end).


-- 
http://bugs.ruby-lang.org/