Re: Should send() be able to take an ArrayBufferView?

2012-04-12 Thread Anne van Kesteren
On Wed, 11 Apr 2012 22:06:07 +0200, Glenn Maynard gl...@zewt.org wrote: I might argue that we shouldn't have ArrayBuffer entry points at all; just ArrayBufferView. It's trivial to create a view on the whole of an ArrayBuffer, and this is leading towards us having two separate entry points for

Re: Should send() be able to take an ArrayBufferView?

2012-04-12 Thread Ian Hickson
On Wed, 11 Apr 2012, Glenn Maynard wrote: That's not really what happens, though. WebSocket gives you an ArrayBuffer if the source is an ArrayBuffer, and a Blob if the source was a Blob No, at the protocol level they are indistinguishable, and at the API level the receiver decides which to

Re: Should send() be able to take an ArrayBufferView?

2012-04-12 Thread Glenn Maynard
On Thu, Apr 12, 2012 at 1:34 PM, Ian Hickson i...@hixie.ch wrote: On Wed, 11 Apr 2012, Glenn Maynard wrote: That's not really what happens, though. WebSocket gives you an ArrayBuffer if the source is an ArrayBuffer, and a Blob if the source was a Blob No, at the protocol level they are

Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
Seems like right now passing a typed array to send() requires a bit of extra hoop-jumping to pass the .buffer instead, right? Is that desirable? -Boris

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Charles Pritchard
Yes; .buffer has stable semantics across many apis. It does feel awkward when first using it, but the design makes sense after some experience. On Apr 11, 2012, at 10:04 AM, Boris Zbarsky bzbar...@mit.edu wrote: Seems like right now passing a typed array to send() requires a bit of extra

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 2:53 PM, Charles Pritchard wrote: Yes; .buffer has stable semantics across many apis. Like what? It does feel awkward when first using it, but the design makes sense after some experience. My point is that we can have overloads taking both ArrayBuffer and ArrayBufferView. Is

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Glenn Maynard
On Wed, Apr 11, 2012 at 12:04 PM, Boris Zbarsky bzbar...@mit.edu wrote: Seems like right now passing a typed array to send() requires a bit of extra hoop-jumping to pass the .buffer instead, right? Is that desirable? It's a bit worse than that, actually: if you want to send only part of a

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 4:06 PM, Glenn Maynard wrote: It's a bit worse than that, actually: if you want to send only part of a buffer, you have to create a whole new ArrayBuffer and copy the data over. If you just pass view.buffer, you'll send the *whole* underlying buffer, not just the slice represented by

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Charles Pritchard
On 4/11/2012 1:16 PM, Boris Zbarsky wrote: On 4/11/12 4:06 PM, Glenn Maynard wrote: It's a bit worse than that, actually: if you want to send only part of a buffer, you have to create a whole new ArrayBuffer and copy the data over. If you just pass view.buffer, you'll send the *whole*

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 4:40 PM, Charles Pritchard wrote: That argues for the removal of the ArrayBuffer overload, indeed, and just leaving the ArrayBufferView version. I've got no idea where TC39 is taking things. ArrayBuffer and ArrayBufferView and such are not specced in TC39 at the moment, and I'm

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Charles Pritchard
On 4/11/2012 1:49 PM, Boris Zbarsky wrote: On 4/11/12 4:40 PM, Charles Pritchard wrote: That argues for the removal of the ArrayBuffer overload, indeed, and just leaving the ArrayBufferView version. I've got no idea where TC39 is taking things. ArrayBuffer and ArrayBufferView and such are

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 5:04 PM, Charles Pritchard wrote: When/if we start using the Binary Data instead of re-purposing typed arrays. Then we'll need to add more send() overloads, probably. What those overloads will be, exactly, depends on the final state of the Binary Data spec. I don't see the

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Charles Pritchard
On 4/11/2012 1:16 PM, Boris Zbarsky wrote: On 4/11/12 4:06 PM, Glenn Maynard wrote: It's a bit worse than that, actually: if you want to send only part of a buffer, you have to create a whole new ArrayBuffer and copy the data over. If you just pass view.buffer, you'll send the *whole*

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 5:28 PM, Charles Pritchard wrote: Adding .send(ArrayBufferView) doesn't seem like it'd hurt anything; it would help in the case of subarray. OK, we agree that far. ;) Removing .send(ArrayBuffer) would hurt things. That seems plausible. I'm more interested in the addition than

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Kenneth Russell
On Wed, Apr 11, 2012 at 10:04 AM, Boris Zbarsky bzbar...@mit.edu wrote: Seems like right now passing a typed array to send() requires a bit of extra hoop-jumping to pass the .buffer instead, right?  Is that desirable? It may be convenient to add an overload to send() (presumably on both XHR and

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Charles Pritchard
On 4/11/2012 2:41 PM, Kenneth Russell wrote: On Wed, Apr 11, 2012 at 10:04 AM, Boris Zbarskybzbar...@mit.edu wrote: Seems like right now passing a typed array to send() requires a bit of extra hoop-jumping to pass the .buffer instead, right? Is that desirable? It may be convenient to add

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 5:41 PM, Kenneth Russell wrote: Sending an ArrayBufferView would still have to use arraybuffer as the type of data. I don't think it would be a good idea to try to instantiate the same subclass of ArrayBufferView on the receiving side. I'm not sure what this means... For

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Kenneth Russell
On Wed, Apr 11, 2012 at 2:47 PM, Charles Pritchard ch...@jumis.com wrote: On 4/11/2012 2:41 PM, Kenneth Russell wrote: On Wed, Apr 11, 2012 at 10:04 AM, Boris Zbarskybzbar...@mit.edu  wrote:  Seems like right now passing a typed array to send() requires a bit of extra  hoop-jumping to

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Charles Pritchard
On 4/11/2012 2:50 PM, Boris Zbarsky wrote: On 4/11/12 5:47 PM, Charles Pritchard wrote: On 4/11/2012 2:41 PM, Kenneth Russell wrote: On Wed, Apr 11, 2012 at 10:04 AM, Boris Zbarskybzbar...@mit.edu wrote: Seems like right now passing a typed array to send() requires a bit of extra

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Kenneth Russell
On Wed, Apr 11, 2012 at 2:48 PM, Boris Zbarsky bzbar...@mit.edu wrote: On 4/11/12 5:41 PM, Kenneth Russell wrote: Sending an ArrayBufferView would still have to use arraybuffer as the type of data. I don't think it would be a good idea to try to instantiate the same subclass of

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Glenn Maynard
On Wed, Apr 11, 2012 at 7:19 PM, Kenneth Russell k...@google.com wrote: On Wed, Apr 11, 2012 at 5:05 PM, Glenn Maynard gl...@zewt.org wrote: (I don't think there's any particular reason for ArrayBuffer to be opaque. It would have been nice if ArrayBuffer acted like an Int8Array, so you can

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 5:54 PM, Charles Pritchard wrote: Note that those have different performance characteristics, too; the latter involves a buffer copy. Are we stuck with a buffer copy (or copy on write) mechanism anyway? Yes-ish; the question is how many copies there are. What is the spec on

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Boris Zbarsky
On 4/11/12 5:54 PM, Kenneth Russell wrote: I haven't looked at WebSocket in enough detail to comment intelligently on it. I haven't really either, but if there were some peer-to-peer support, then the receiving peer should still get an ArrayBuffer even if the sender sent an ArrayBufferView.

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Jarred Nicholls
On Wed, Apr 11, 2012 at 5:54 PM, Kenneth Russell k...@google.com wrote: On Wed, Apr 11, 2012 at 2:48 PM, Boris Zbarsky bzbar...@mit.edu wrote: On 4/11/12 5:41 PM, Kenneth Russell wrote: Sending an ArrayBufferView would still have to use arraybuffer as the type of data. I don't think it

Re: Should send() be able to take an ArrayBufferView?

2012-04-11 Thread Glenn Maynard
On Wed, Apr 11, 2012 at 8:15 PM, Boris Zbarsky bzbar...@mit.edu wrote: On 4/11/12 5:54 PM, Charles Pritchard wrote: Note that those have different performance characteristics, too; the latter involves a buffer copy. Are we stuck with a buffer copy (or copy on write) mechanism anyway?