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

Re: How to correctly spec sequences requiring an iterable

From: Boris Zbarsky <bzbarsky@MIT.EDU>
Date: Mon, 18 Nov 2013 12:59:48 -0500
Message-ID: <528A5594.7000901@mit.edu>
To: public-script-coord@w3.org
On 11/15/13 2:02 PM, Boris Zbarsky wrote:
> Now either jQuery is full of bad API design here, or people actually
> want APIs like this in some cases...

This thread died after I sent that, apparently.

My current plan in WebIDL is to spec sequence<> as follows, with the 
incoming value as "val":

1) If val is not an object, move on to the next union member (or throw
    an exception if none left).  This allows a union of sequence and
    string, and is the current behavior of sequences anyway.
2) Do iter = Get(val, @@iterator).  ReturnIfAbrupt.
3) If the value is not an object or is not callable, move on to the
    next union member.
4) Commit to treating this as a sequence.
5) iterator = iter.call(val);
6) Walk through with IteratorStep/IteratorValue etc, converting each
    sequence element before stepping to the next one.

Does anyone see any obvious problems with that other than the 
(controversial) object check in step 1?

-Boris
Received on Monday, 18 November 2013 18:00:17 UTC

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