Hi,

In message "Re: Symbol < String in Ruby > 1.8"
    on Thu, 19 Oct 2006 14:08:07 +0900, Sam Roberts <sroberts / uniserve.com> writes:

|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.

Interesting.  All strings?  Is the result of string substitution, for
example, also interned?

|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.

Module can not rely on the internal structure of object, so that all
methods defined in the module (Textual?) should be based on some
primitive methods.  For example, methods in Enumerable are based on
#each (and several others).  I am not sure we can define such
primitives for Textual methods, without hindering the performance.

Besides that, making two independent classes, String and Symbol (or
InternedString or whatever) is rather trivial.  I can do it in 10
minutes or so.  The point is the rationale, and trade-off.

							matz.