Re: Guidance on using sequences and arrays

On 6/26/13 6:15 AM, Marcos Caceres wrote:
> What I'm confused about is what does "readonly" mean in the above. Clearly, it means that the reference of the array in the attribute can't be changed - but what about the content of the array?

Undefined.  There are three different kinds of Call[] defined in WebIDL: 
readonly, fixed-length, and writable.  There is no way to differentiate 
between them in IDL (a bug, imo), so you have to say in prose what kind 
yours is.

> Can a developer do the following:
>
> telephony.calls.pop();
> telephony.calls.push(SomeOldCallObj);
>
> If so, that would obviously be bad.

Then you presumably want a readonly array.

> Would it then be appropriate to change the calls attribute to a sequence (i.e., sequence<Call> getCalls())?

Here's the right litmus test for this.  If a developer does:

   myCalls = telephonymanager.calls;

Do we then want them to see the contents of myCalls change as the set of 
calls the UA manages changes?  If so, you want a readonly Call[] here. 
If not, you want a sequence.  Which behavior you want is "just" an API 
design decision, as far as I can tell

-Boris

Received on Wednesday, 26 June 2013 13:45:30 UTC