Quoting matz / ruby-lang.org, on Thu, Oct 19, 2006 at 01:40:42PM +0900:
> In message "Re: Symbol < String in Ruby > 1.8"
>     on Thu, 19 Oct 2006 07:56:56 +0900, Sam Roberts <sroberts / uniserve.com> writes:
> 
> |If the only difference is that Symbol is immutable, and its too weird to
> |have String be a sub-class of Symbol with more methods, maybe the
> |
> |  :athing
> |
> |notation could make an ImmutableString, a base class of String, where
> |
> |  :athing.object_id == :athing.object_id # => true
> 
> I had an idea that renaming Symbol to InternedString (and making
> Symbol as an alias to it), but not considered it in deep yet.

Been working with lua recently (lua.org), it only has immutable strings,
so all strings are effectively interned at creation, comparison between
them is "cheap" after that, and memory is collapsed because there is
never more than one instance of the same string.

I like being able to mutate strings in ruby, and wouldn't want to lose
that, but there are attractions to the immutable string concept.

One nice thing about having two kinds of string related by a mixin
instead of inheritance, like InternedString/Symbol and String both
mixing in Textual rather than String inheriting from InternedString, is
that the mixin may be usable by other classes that also want to be
duck-typeable as strings, but don't want to implement all the many, many
methods of String. It might be hard to figure out the right breakdown
between class and Textual mixin, but it sure would be nice.

Sam