On Fri, 2002-07-05 at 12:31, Hal E. Fulton wrote:
> No, I have to say that in this respect as in others,
> Ruby corrected C's mistake. And it was not really
> and truly a mistake in C; C is close to assembly
> language, and is not as high level as Ruby. There
> was not really another way to think of strings 
> except as arrays. But we're past that now.

like c was the only languge before ruby came along?

strings have been delt with in all sorts of ways by "higher-level"
languages.

but when you get down to the core of it, strings are ultimaltly stored
as ordered sets of data. the difference for ruby really amounts to the
fact that the ordered set of data for a ruby Array consists of reference
pointers to Objects, where as the String consists of the actual
character bytecodes. if a String were to work just like the Array and
instead point to encoding-specific Character Objects, we'd get a much
more powerful and "internationalizable" model, but at a significant cost
to speed. so there is reason to have them as different types of objects.

but, to satisfy POLS, since they are the same type of data structure
(the String differing only in the types of objects in COULD point to)
the String should "inherit" essentially all the exact same methods as
Array and those should work in the same fashion. that is POLS!

~transami
 

> ----- Original Message ----- 
> From: "Michael Campbell" <michael_s_campbell / yahoo.com>
> To: "ruby-talk ML" <ruby-talk / ruby-lang.org>
> Sent: Friday, July 05, 2002 11:07 AM
> Subject: Re: is there a better string.each?
> 
> 
> > > This is something which bites everybody, I think, at some point.
> > 
> > Not to be a pedant, but this seems like a huge breakage of the POLS,
> > if it bites everyone, no?   =)
> 
> I see your point, but I disagree.
> 
> If Ruby behaved identically to C, then the
> surprise for C programmers would be precisely
> zero.
> 
> But when you use C for string processing (especially
> when you've used something more powerful), you find 
> yourself saying: "There should be some easy way to
> do THIS..."
> 
> In the first place, POLS is a Matz-centric phenomenon
> (as he has admitted). The more you think like Matz,
> the better you will understand Ruby.
> 
> Secondly, POLS should be a meta-linguistic issue IMO --
> not "how does this work in my favorite language?" but
> "how *should* this work in an ideal universe?"
> 
> And I think Strings are not really Arrays. There are
> some isomorphisms there, since they are both "ordered
> collections of entities."
> 
> But a string is a highly specialized thing. For one
> thing, each item has to be a character. No other 
> Ruby array is limited in the kind of data it can
> contain; such an idea seems very unRubylike to me.
> 
> No, I have to say that in this respect as in others,
> Ruby corrected C's mistake. And it was not really
> and truly a mistake in C; C is close to assembly
> language, and is not as high level as Ruby. There
> was not really another way to think of strings 
> except as arrays. But we're past that now.
> 
> Hal Fulton
> 
> 
> 
-- 
~transami

"They that can give up essential liberty to obtain a little
 temporary safety deserve neither liberty nor safety."
	-- Benjamin Franklin