[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Public WebGL] TypedArray constructors and zero length

Hey Vlad,

On Thu, Jun 10, 2010 at 01:42, Vladimir Vukicevic <vladimir@mozilla.com> wrote:
0 is a valid length; you should be able to create 0-length arrays as necessary, otherwise there's no way to represent a valid empty array.  You'd have to pass null, which means special casing everything that works with arrays to understand null.

Zero-length arrays might make sense but zero-length buffers ? I see ArrayBuffer as a way to efficiently allocate packed (buffer) memory from _javascript_, hence my question about such behavior (ie. malloc(0) or equivalent on some GCs will fail).

Not sure to get what you imply by "special casing everything that works with arrays" ?
TypedArray are interface types so null is already a potential 'legal' value to take care of afaik.

In my understanding supporting 0-length arrays requires additional special casing on top of that, for avoiding divide by zero and internal memory housekeeping.

And as the length is already unsigned, then it can't ever be negative, so I don't think we need to do any special language here.

I see, so what should happen in this case ? TYPE_ERR ?