Re: [heycam/webidl] Add and improve operations on BufferSources (#987)

I added BufferSource/is detached for now.

On the others, it occured to me that we have two directions here: super-polymorphism, where everything is defined on BufferSources, or something more true to the model where ArrayBuffers are special. I was curious for your thoughts.

Super-polymorphism:
  - Maybe merge ArrayBuffer/create and ArrayBufferView/create into BufferSource/create (with ArrayBuffer just being one of the types you can specify)
  - Merge ArrayBuffer/write and ArrayBufferView/write
  - Replace ArrayBuffer/detach with BufferSource/detach
  - Replace ArrayBuffer/transfer BufferSource/transfer

ArrayBuffers are special:

  - Define ArrayBufferView/get the underlying ArrayBuffer
  - Don't define ArrayBufferView/transfer or ArrayBufferView/detach; make it clear that you're reaching below the view level and messing with the buffer beneath
  - Maybe change BufferSource/is detached to just ArrayBuffer/is detached, for similar reasons (although it's less important for introspection)
  - Probably keep ArrayBuffer/write and ArrayBufferView/write separate, to make it clear when you're writing into a view that you only have influence over the view's range

> Is "get a reference to the bytes held by the buffer source" used anywhere?

The one place I was aware of was Encoding. But I just thought to check a bit more and [Web Audio](https://webaudio.github.io/web-audio-api/) is a heavy consumer. I should prepare a PR for them before we merge this.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/heycam/webidl/pull/987#issuecomment-868000679

Received on Thursday, 24 June 2021 22:42:09 UTC