Re: [WebIDL] Sequences and arrays

2009-07-07 Thread Giovanni Campagna
Only one comment:
it should be noted that with
interface Example {
sequence numbers;
}

In EcmaScript ex.numbers != ex.numbers, because each access to
"numbers" creates a new Array
This is probably counterintuitive to most users of the interface and
may prevent many uses of sequence<> as attributes (to avoid such
confusion).

Giovanni

2009/7/7 Cameron McCormack :
> Hello WG.
>
> I’ve finally fixed up sequences in Web IDL, and also added an array
> type.  The difference is that:
>
>  * sequences are effectively pass-by-value, represented by a JS Array
>    or a Java array object, and
>
>  * arrays are pass-by-reference, represented by a JS host object that
>    acts similarly to an Array (including having Array.prototype in its
>    prototype chain, but not supporting sparse arrays) or by a Java
>    object that implements an interface defined in the spec that allows
>    access to elements and the array length.
>
> JS Array objects can also be passed to host objects expecting an array,
> but the Array object will be converted into the special host object.
>
>  http://dev.w3.org/2006/webapi/WebIDL/#idl-sequence
>  http://dev.w3.org/2006/webapi/WebIDL/#idl-array
>
>  http://dev.w3.org/2006/webapi/WebIDL/#es-sequence
>  http://dev.w3.org/2006/webapi/WebIDL/#es-array
>
>  http://dev.w3.org/2006/webapi/WebIDL/#java-sequence
>  http://dev.w3.org/2006/webapi/WebIDL/#java-array
>
> Comments welcome.
>
> --
> Cameron McCormack ≝ http://mcc.id.au/
>
>



Re: [WebIDL] Sequences and arrays

2009-07-07 Thread Cameron McCormack
Giovanni Campagna:
> Only one comment:
> it should be noted that with
> interface Example {
> sequence numbers;
> }
> 
> In EcmaScript ex.numbers != ex.numbers, because each access to
> "numbers" creates a new Array
> This is probably counterintuitive to most users of the interface and
> may prevent many uses of sequence<> as attributes (to avoid such
> confusion).

Yes that’s a good point.  I’ve added such a note:

  http://dev.w3.org/2006/webapi/WebIDL/#idl-sequence

pointed it out in the ECMAScript sequence example:

  http://dev.w3.org/2006/webapi/WebIDL/#es-sequence

and added the concept of a “read only” array:

  http://dev.w3.org/2006/webapi/WebIDL/#dfn-read-only-array

In the added note I suggest to use read only arrays instead of sequences
for attribute types.

Thanks,

Cameron

-- 
Cameron McCormack ≝ http://mcc.id.au/