On 2010-02-08, Marnen Laibow-Koser <marnen / marnen.org> wrote:
> I haven't used 1.9 yet, so take this with a grain of salt, but my 
> impression is that encoding-aware Strings that aren't byte arrays is 
> exactly the right thing for Ruby to have.

It is certainly a useful thing to have, but I'm not sure that it's a good
idea to do away with byte arrays.

I have a program which listens for UDP packets containing a hunk of data,
which is a string of binary bits and pieces, such as 3-byte integer values,
flag bits, and so on.  I can't change the format of the packets.  I have
some Ruby code which is doing the obvious thing -- taking the byte arrays
that are returned as string objects by the underlying syscall, and managing
it using unpack(), etcetera.

If strings are not the right tool for holding hunks of binary data, such as
those you'd get from performing a raw binary read(2) on a data file, what is?
The array type seems INCREDIBLY expensive for this -- do I really want to
allocate over two thousand objects to read in a 2KB chunk of data?

-s
-- 
Copyright 2010, all wrongs reversed.  Peter Seebach / usenet-nospam / seebs.net
http://www.seebs.net/log/ <-- lawsuits, religion, and funny pictures
http://en.wikipedia.org/wiki/Fair_Game_(Scientology) <-- get educated!