From: Mathieu Bouchard Date: 2002-01-28T05:04:28+09:00 Subject: Re: Subrange of String subclass => invalid object On Mon, 28 Jan 2002, Dave Thomas wrote: > So, I'm thinking that perhaps something to think about in Rite is > having built-in frozen classes for primitive types, _String, and so > on. These classes would be no more that value containers: they'd have > almost no operators. The implementations of String could then be > expressed in terms of operations on these _Strings (probably by > delegating to them, rather than subclassing them). You don't need delegation here. I'm thinking of two solutions: class SimpleString # implemented in C end class String < SimpleString; include HollowString; end and: class String; include HollowString # equivalent of SimpleString in C goes here end the second one is acceptable. you don't need to handle objects of a lesser String class when you can mix in the whole functionality directly. There only needs to be a clear semantics of which String class is used where, and in the SimpleString protocol, the C-based one is the mandated one for operations like "get substring" and "replace substring by other substring"; in higher-level parts of the protocol it's different. I don't know why you could need the first solution above instead of the second one. > We could rewrite the whole String class in Ruby just to experiment > with new behaviors. This is all very inspiring, but... Are we in january 2002, or january 2001 ? anyway, if "we" are going to start somewhere, "we" are better rewriting the Regexp class and fixing Ruby's scoping of $1,etc., instead of redoing what's been already done. ________________________________________________________________ Mathieu Bouchard http://hostname.2y.net/~matju