W3C home > Mailing lists > Public > public-webapps@w3.org > April to June 2012

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

From: Glenn Maynard <glenn@zewt.org>
Date: Sun, 29 Apr 2012 15:32:59 -0500
Message-ID: <CABirCh_tu0GZU9TuK_Z-T3jeTc_fV2k3s9=ViXNLkV_Qh5uStQ@mail.gmail.com>
To: Jonas Sicking <jonas@sicking.cc>
Cc: Arun Ranganathan <aranganathan@mozilla.com>, Anne van Kesteren <annevk@opera.com>, David Herman <dherman@mozilla.com>, Eric U <ericu@google.com>, Boris Zbarsky <bzbarsky@mit.edu>, public-webapps@w3.org
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 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 18:49:52 GMT