Dave Thomas wrote:
> 
> ts <decoux / moulon.inra.fr> writes:
> 
> > >>>>> "D" == Dave Thomas <Dave / PragmaticProgrammer.com> writes:
> >
> > D>                                                        I'm guessing
> > D> that the Foo object is undergoing the same treatment, and therefore
> > D> that Ruby can't tell the resulting copied key from the next "hello"
> > D> that comes along.
> >
> >  In reality this is because you can't change String#hash.
> >
> >   Well, you can, but ruby will not use it internally (this was why I've
> > said "but don't try to redefine #hash for String" in [ruby-talk:8034])
> 
> But you should be able to subclass String and use it as a hash key. I
> think that the special treatments that Strings receive should only
> appear to class == String. Subclasses of string should be treated like
> any other object.
> 
> This will even have the correct default behavior, as if the sub class
> doesn't define eql? and hash, it will be treated identically to a
> String, and hence we'll see the existing behavior.
> 
> Regards
> 
> Dave

This may be an ignorant comment, but why should class String, itself,
receive special treatment?  Seems unaesthetic to me, although it must
surely allow a lot of performance optimizations.

craig