On 6/26/06, Tim Bray <tbray / textuality.com> wrote:
> On Jun 25, 2006, at 6:11 PM, Austin Ziegler wrote:
> > Under the people who want separate ByteVector and String class, I'll
> > need *two* APIs:
> >
> >  st = File.open("file.txt", "rb") { |f| f.read_string }
> >  bv = File.open("file.txt", "rb") { |f| f.read_bytes }
> Maybe I'm missing something, but in today's networked heterogeneous
> environment, that first call looks deeply dangerous to me.  I don't
> see how you can expect to get a String out of a file in the general
> case.  Files contain bytes, strings contain characters, and
> pretending you can get from one to the other without explicit
> encoding specification or inference is unsound.

Um. You're not missing anything -- I'm mocking the API pair that would
be required to make this work as certain advocates have suggested.

> Pardon me if I'm missing something obvious. -Tim

You're not. IO should be done on byte buffers. There's no meaningful
and useful distinction between a byte buffer and a string at the most
basic level. There's an additional interpretation that's possible at a
higher level (giving character-oriented operations), but that in and
of itself does not imply a need for a separation of the two concepts.
(Indeed, I find myself infuriated in C++ when I have to do something
that would work well with std::vector<unsigned char> and I'm actually
working with std::string -- or vice versa.)

-austin
-- 
Austin Ziegler * halostatue / gmail.com * http://www.halostatue.ca/
               * austin / halostatue.ca * http://www.halostatue.ca/feed/
               * austin / zieglers.ca