Re: WaveShaperNode.curve

On Tue, May 14, 2013 at 2:58 PM, Srikumar Karaikudi Subramanian <> wrote:

> shaper.curve = new Float32Array(100);
>>> for (var i = 0; i < 100; ++i) {
>>>   // oops, at this point the array has been internally copied,
>>>   // and while the code below doesn't throw an exception,
>>>   // it effectively sets the curve property to an all-0 array,
>>>   // which is not what the author has intended.
>>>   shaper.curve[i] = whatever;
>>> }
> This code will bomb anyway if the array is neutered after setting the
> curve (the length of a
> neutered array is 0).

That's a good thing. Code that fails obviously and synchronously is better
than code that silently fails to work, from the point of view of an author
trying to find bugs.

> Furthermore, what would be
> the point of having a getter for the shaper.curve property if all it will
> provide is a neutered array?
> RoC's suggestion of a setCurve() without a getter is in this case a much
> cleaner solution.

We could arrange for the getter of 'curve' to return a new non-neutered
array, with the old contents, if the original array has been neutered.

> In general, please consider whether any "setBlah" qualifies as a full
> property before
> also including a getter for it. In this case, what we (devs) really need
> is a write-only property
> to avoid all this potential confusion. A setCurve() will offer a clear
> point where any consistency
> checks on the array can be expected to be performed.

Sounds good to me :-). Maybe we could add setCurve(), deprecate the
attribute, make setting the attribute neuter the array, and make getting
the attribute return a new array with the latest curve data.

q“qIqfq qyqoquq qlqoqvqeq qtqhqoqsqeq qwqhqoq qlqoqvqeq qyqoquq,q qwqhqaqtq
qcqrqeqdqiqtq qiqsq qtqhqaqtq qtqoq qyqoquq?q qEqvqeqnq qsqiqnqnqeqrqsq
qlqoqvqeq qtqhqoqsqeq qwqhqoq qlqoqvqeq qtqhqeqmq.q qAqnqdq qiqfq qyqoquq
qdqoq qgqoqoqdq qtqoq qtqhqoqsqeq qwqhqoq qaqrqeq qgqoqoqdq qtqoq qyqoquq,q
qwqhqaqtq qcqrqeqdqiqtq qiqsq qtqhqaqtq qtqoq qyqoquq?q qEqvqeqnq
qsqiqnqnqeqrqsq qdqoq qtqhqaqtq.q"

Received on Tuesday, 14 May 2013 03:38:23 UTC