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: Fri, 15 Nov 2013 12:42:02 -0500
Message-ID: <52865CEA.6000805@mit.edu>
To: Allen Wirfs-Brock <allen@wirfs-brock.com>, Jason Orendorff <jason.orendorff@gmail.com>
CC: public-script-coord@w3.org
On 11/15/13 12:28 PM, Allen Wirfs-Brock wrote:
> Currently, Array.from [2] does a HasProperty(@@iterator) check followed
> by a call to GetIterator.   In other words, the existence of an
> @@iterator property is all that is need to select the Iterator side of
> the union type.  But that is then followed by validation specified via
> GetIterator.  If the value of @@iterator doesn't validate you get a
> runtime exception rather than a fall back to the other side of the union
> type.

For what's that's worth, that's basically my situation.  Once I commit 
to treating as a sequence, I'd go ahead and do the equivalent of 
GetIterator, and if it throws it throws.

The question is what criteria need to be met to treat as a sequence.

> There is one detail of the above that I think should change.  Rather
> than doing HasProperty(@@iterator) to make the union type
> discrimination, it should do:
>       6    Let iteratorGetter = Get(items, @@iterator).
>       7.5 If iteratorGetter is undefined or null then let usingIterator
> be false; otherwise let usingIterator be true.

OK.  We can just align WebIDL with this, I think, as long as people are 
happy enough about that.

>      An object is an iterable if it has a @@iterator whose value is
> neither undefined or null.

OK.  And a primitive string, e.g., should not be considered iterable for 
my purposes, right?

Thank you for thinking about this,
Boris
Received on Friday, 15 November 2013 17:42:32 UTC

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