That’s a big one, and it would be something that needs to be addressed in Ruby, not in Rails. But the problem is that you would have unintuitive behavior for those used to doing things like:
s = ‘Error’
In today’s Ruby and jruby-1.7.0.preview2:
jruby-1.7.0.preview2 :001 > “Error”.object_id
jruby-1.7.0.preview2 :002 > “Error”.object_id
jruby-1.7.0.preview2 :003 > “Error”.chomp!(‘or’).object_id
jruby-1.7.0.preview2 :004 > s = “Error”
jruby-1.7.0.preview2 :005 > s.object_id
jruby-1.7.0.preview2 :006 > s.chomp!(‘or’)
jruby-1.7.0.preview2 :007 > s.object_id
See, when you are just working with strings willy nilly, it creates new instances and you don’t have to worry about things like the “bang” methods altering the same object.
In a StringPool’d ruby, the bang methods would need to return a string that was the same object_id so that past implementations that depend on object equivalence would still work, but it could not alter the “Error” string in the StringPool or things would go terribly wrong.
Feel free to take this up on the ruby list, and post back the link. I’m sure that those guys could figure out a way to make it work if they’ve not already discussed it, but my guess is it would be a breaking major change, even if it is necessary to reduce # of objects and make things faster.