From: KOSAKI Motohiro Date: 2015-11-04T22:00:12-05:00 Subject: [ruby-core:71343] Re: [Ruby trunk - Feature #8976] file-scope freeze_string directive > Shugo Maeda wrote: > >> It's not just for compatibility. >> >> The original problem was that a new String object has to be allocated by a string literal >> for each evaluation. So I don't understand the reason why a dynamic string literal should >> be frozen in spite of the fact freezing dynamic strings can't reduce object allocation. > > It is not a big problem. > We can reduce extra object allocation with "foo#{exp}bar".dup using an optimization similar for "foo".freeze. > > I think the pragma and option name should explain the behavior. > The name is "frozen-string-literal". > So, basically, all string literal should return a frozen object. > > We need an explanation if we introduce an exception. +1 Current explanation is too weak to make an exception, I think.