Jeremy Bopp wrote in post #1013121:
> I'm trying to think of a way to allow the interpreter to cheat with
> regard to string literals such that until the program attempts to modify
> the literal or otherwise pierce the veil (calling object_id or similar)
> the program actually uses the literal's object instance directly.  This
> would allow the interpreter to avoid allocating extra string objects for
> literals until they actually need to be modified or attributes such as
> the object identity need to be known.  I'm not sure this is possible or
> would even yield any performance benefits.  It's more of a curiosity
> now.

It's probably not worth the effort because for a short script you won't 
notice and for other applications the user still can use a constant and 
freeze the String.  Plus, it will be tough for the interpreter to 
_reliably_ detect when a string literal is not changed.  IMHO the 
current solution is good enough.

> Thanks again for your help.

You're welcome!

Kind regards

robert

-- 
Posted via http://www.ruby-forum.com/.