Re: BlobBuilder.append() should take ArrayBufferView in addition to ArrayBuffer

On Sun, Apr 29, 2012 at 2:41 PM, Jonas Sicking <jonas@sicking.cc> wrote:

> I don't know what you are using as basis for the "it's probably by far
> the most common actual data type" statement.
>

Every multibyte string is an array of bytes.  Compressed data is an arrays
of bytes (or rather bitstreams, which are accessed as bytes).  Files and
network requests which are entirely arrays of 16- or 32-bit units are
pretty uncommon.

The whole point of the ArrayBuffer/ArrayBufferView split is that
> ArrayBuffers represent data of which you don't know the type, whereas
> ArrayBufferView is for when you know the type.
>

No, that's not the point.  DataView is an ArrayBufferView, and DataView
isn't typed.  The whole point of the ArrayBuffer/ArrayBufferView split is
that ArrayBuffer represents storage, where ArrayBufferView represents a
lightweight slice of that storage.  It's perfectly fine to create an
Int8Array from a slice of an ArrayBuffer, even if the data is really 32-bit
floats, when you don't care about the contents and just want to create a
slice.  (You can do that with DataView, too, but there's nothing wrong with
using Int8Array for this.)

You might not like that design (I don't), but it's what we have.
> Hopefully ES6 will grow something better at which time we can support
> that.
>

Having two APIs for the same thing, even if it's better designed, seems
likely to cost more than the gain.  If we *really* think that this is going
to happen, it might be a bad idea to add ArrayBuffer to more and more
APIs...

-- 
Glenn Maynard

Received on Sunday, 29 April 2012 20:33:28 UTC