From: Nikolai Weibull Date: 2009-12-02T08:59:05+09:00 Subject: [ruby-core:26989] Re: Caching #to_s for immutables (and a possible future for constant-folding) [with patch v2] On Wed, Dec 2, 2009 at 00:42, Kurt Stephens wrote: > Nikolai Weibull wrote: >> >> On Tue, Dec 1, 2009 at 18:19, Yusuke ENDOH wrote: >> >>> How about if #to_s returns, instead of a frozen String itself, a mutable >>> String that is duplicated from the cached frozen String? >> >> Couldn���t one delay duplication until mutation? >> > If Ruby passed arguments by name, not value... :). Silly me. I was actually thinking of returning a proxy that would substitute itself with the duplicated value upon mutation, but that would create additional objects and would probably be rather complicated and probably wouldn't work. Oh, if only Ruby had immutable strings, how sweet the world world would be.