W3C home > Mailing lists > Public > public-script-coord@w3.org > April to June 2013

Re: Guidance on using sequences and arrays

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Wed, 26 Jun 2013 09:44:58 -0400
Message-ID: <51CAF05A.9010807@mit.edu>
To: public-script-coord@w3.org
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

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

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