Re: How to correctly spec sequences requiring an iterable

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