Re: How to correctly spec sequences requiring an iterable

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