From: Dave Thomas Date: 2002-01-28T11:32:21+09:00 Subject: Re: Subrange of String subclass => invalid object Mathieu Bouchard writes: > > > > We could rewrite the whole String class in Ruby just to > > > > experiment with new behaviors. > > > Are we in january 2002, or january 2001 ? > > Have the needs changed? And are we any further along? > > well, i've rewritten Array/Hash/String, i've experimented with new > behaviours, and i talked about it on ruby-talk. then months after > that, you say: we could rewrite the whole String class and > experiment with new behaviours. You have some interesting code. But the String literal "fred" is still a special case inside the interpreter, and no amount of external code is going to change that. Without support from within, you're still never going to be able to integrate an externally written String, or Hash, or whatever into the main language. But let's say we want to (and I'd like to). So then you have the issue of how that internal support is going to communicate the characters 'f', 'r', 'e', and 'd' to your String class's constructor, written in Ruby itself. It _could_ pass an array of ints representing characters, but going with that representation is going to be awfully inefficient every time a String needs to cross from the Ruby world to the external world. Hence the need for a helper class like _String, a container to encapsulate the real-world representation of strings. Until that comes along (and it might come along with other Ruby interpreters being written) we're not really closer to the idea of being able to write a practical String class in Ruby. > Frankly, I don't know what to think. I certainly didn't mean to offend. Dave