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

Re: How to correctly spec sequences requiring an iterable

From: Allen Wirfs-Brock <allen@wirfs-brock.com>
Date: Fri, 15 Nov 2013 10:28:59 -0800
Cc: Boris Zbarsky <bzbarsky@MIT.EDU>, Jason Orendorff <jason.orendorff@gmail.com>, "public-script-coord@w3.org" <public-script-coord@w3.org>
Message-Id: <4FFD96D5-8DF2-49BA-B8A9-4DA5D71713B5@wirfs-brock.com>
To: Domenic Denicola <domenic@domenicdenicola.com>

On Nov 15, 2013, at 9:58 AM, Domenic Denicola wrote:

> From: Allen Wirfs-Brock <allen@wirfs-brock.com>
>> As current spec'ed  GetIterator("primitiveString") does in fact work with primitive strings.  So, any conditional Iterable test also needs to consider a primitive string to be an Iterable. This isn't currently correctly handled in the ES6 spec.  It's a new bug that I will fix.
> Sorry, I wasn't quite clear---what do you consider correct, and what do you consider a bug? Is `for`-`of` supposed to work with strings? What about `Array.from`? What about `Promise.all`?

Primitive string values behave as objects that inherit from String.prototype which as a @@iterator method.  That means that a primitive string value should be usable in all contexts that requires an Iterable.  That includes for-of,  Array.from, and Promise.all  EG,

for (let char of "abc\u{1f61c}xyz") ...
let chars = Array.from("abc\u{1f61c}xyz");

For Promise.all, it presumably makes just as just as much sense as:

Received on Friday, 15 November 2013 18:29:33 UTC

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