W3C home > Mailing lists > Public > public-script-coord@w3.org > January to March 2015

Re: Idiomatic representation of { buffer, bytesRead }

From: Jason Orendorff <jason.orendorff@gmail.com>
Date: Wed, 4 Mar 2015 16:10:33 -0600
Message-ID: <CAPh8+Zr8=xoCBKVgtBEVT5Y2on9sxMpKVdLgyTUhrb1nkhFFzw@mail.gmail.com>
To: Domenic Denicola <d@domenic.me>
Cc: "es-discuss@mozilla.org" <es-discuss@mozilla.org>, "public-script-coord@w3.org" <public-script-coord@w3.org>
On Wed, Mar 4, 2015 at 3:06 PM, Domenic Denicola <d@domenic.me> wrote:
> I thought of that. However, I found it a bit strange that passing this function a view onto bytes [256, 512] of a 1024-byte buffer would detach the entire 1024-byte buffer. What do you think?

It's a good point. I figured most callers will have allocated the
buffer themselves, most will only have one view into it at a time, and
most will ask for the whole thing to be filled; and by "most" I really
mean somewhere over 99.9%. Skimming your gist seemed to sort of
confirm my hunch, but don't take my word for it -- that's all the
research I did. All I know is, I've known about Python's
for at least 15 years and never yet had a need for it.

Would it make it seem less strange if you specified the argument as a
"dictionary" with these properties:

    {buffer:, byteOffset:, byteLength:, constructor:}

...and then casually mention that DataViews and TypedArrays both
happen to quack in just this way?

Received on Wednesday, 4 March 2015 22:11:00 UTC

This archive was generated by hypermail 2.4.0 : Friday, 17 January 2020 17:14:24 UTC