On Sep 6, 12:50 am, Brian Candler <B.Cand... / pobox.com> wrote:
> I just had a thought.

<snip>

> However, since I've seen discussion about string modifiers like "..."u,
> perhaps there's scope for adding in-language support, e.g.
>
>     "..."f     - frozen string, same object ID each time it's executed
>
> In that case, it might be more convenient the other way round:
>
>    "..."              - frozen string literal, same object
>    "..."m             - mutable (unfrozen) string literal, new objects
>    String.new("...")  - another way of making a mutable string
>    "...".dup          - and another

Rubinius has a compiler extension that detects code in the form of

  "name".static

Inside the quotes can be any string, and the static method call is
removed,
but everytime the code is run, the same String object is returned.
This is
highly useful when using strings as hash keys, and avoids having to
put them
in constants that must be looked up later.

>
> That would break a lot of existing code, but it could be pragma-enabled.
>
> Sorry if this ground has been covered before - it's hard to keep up with
> ruby-talk :-)
>
> Regards,
>
> Brian.

 - Evan Phoenix