Re: [XHR2] responseBody (byte array)

> On Jul 27, 2007, at 8:49 AM, Anne van Kesteren wrote:
> > I'm planning to specify it as an Array of unsigned integers. Hopefully this will
>> be compatible with whatever ES4 introduces for byte arrays.

On 29/07/07, Maciej Stachowiak <mjs@apple.com> wrote:
> I don't think it will be - a ByteArray is not an Array, in the current
> proposal. I think it would be better to either steal the ES4 ByteArray
> definition (it's not really tied to the rest of the language) or make
> up a custom interface for an octet sequence. An Array of unsigned
> integers is a very inefficient way to encode binary data, it will blow
> out the memory requirements by at least 4x.

I think it would be a good idea to reuse the same interface or use an
interface that is in as many ways as possible identical. An ES3 Array
(which is a hashtable with String keys corresponding to the
stringification of Number values that are uint32 values) of uints (in
reality Number constrained to the value range of a uint8) is not even
close to as efficient as an ES4 ByteArray. I'd prefer a custom
interface to that one, if using ES4 ByteArray straight off is not an
option - though ES4 ByteArray should be implementable in ES3 engines,
so inventing a custom interface instead of backporting the ES4 one is
just adding cruft in my opinion.

> > My plan for send() is that if it's passed an Array which contains
> > non-unsigned integers that those are converted to 0 and that
> > unsigned integers larger than 255 are converted to 255.
>
> Here again I think a real ByteArray type would work better, though I
> think allowing an Array in this case is also ok.
>
> See http://developer.mozilla.org/es4/proposals/bytearray.html for
> details on the proposal.

The ES4 public export wiki is getting out of date, so that might not
be a good link. I think the ByteArray interface has been fleshed out
considerably compared to that one. I appended the source from the M0
pre-release of the refimpl in
<uri:http://lists.w3.org/Archives/Public/public-webapi/2007Jun/0128.html>.
Those sources should be more in line with the current state of the ES4
spec.
-- 
David "liorean" Andersson

Received on Monday, 30 July 2007 18:45:40 UTC