From: Austin Ziegler Date: 2002-07-08T07:01:40+09:00 Subject: Re: is there a better string.each? On Mon, 8 Jul 2002 06:30:30 +0900, Tom Sawyer wrote: > i don't program in c/c++. > > anyway, it dosen't matter. the point is simply that strings are an > ordered list of characters. arrays are order lists of objects. in > so far as the two are common, i want the same methods for both. no > suprises. that's all. I think what we're trying to get at is that the C/C++ model of char* or char[] is broken -- or at least too close to the implementation to be called a decent model. I have other reasons for believing that the C++ STL std::string is broken, mostly due to implementation failures and a widespread lack of support up to last year on several relatively recent compilers. C/C++ char[] strings require a NULL character at the end of the string to terminate it -- even if you know the length of the string. Do you want to require that behaviour in Ruby, or might you want a string that knows its length? The implementation isn't the same as the API, and while it is sometimes useful to treat a string as an array, I haven't seen a great need for it outside of C/C++ char[] strings which can't do a third of what Ruby or Perl strings will do without three times as much code. I just checked an application that I forked recently -- there's not a single time that I've had to delve into a Perl string as an array, and there's close to 4000 LOC. -austin -- Austin Ziegler, austin@halostatue.ca on 2002.07.07 at 17.49.32