Why does Array.from accept non-iterable arraylikes?

Dean Landolt dean at deanlandolt.com
Tue Jun 25 12:36:14 PDT 2013


On Tue, Jun 25, 2013 at 2:16 PM, Brandon Benvie <bbenvie at mozilla.com> wrote:

> On 6/25/2013 10:33 AM, Allen Wirfs-Brock wrote:
>
>> We could make an exception for iterator, but why? That just introduces an
>> inconsistency in the design.
>>
>
> I think the motivation was to make it easier to polyfill, but I don't
> think that argument holds for @@iterator. If you're attempting to polyfill
> iteration, then you have to polyfill both ends of it; you have to supply
> both the iterators as well as functions to consume those iterators (since
> you can't polyfill for-of). That means you have control over the protocol,
> and can opt to use something like "__iterator__".



You could, but your polyfills probably won't play well with other polyfills
unless TC39 specifies a hook (normative or otherwise). Again, if the
platform were to also define a secondary, static way to get and set an
object's *iterator* a la Object.getPrototypeOf the interop problem is
solved. It's hideous, sure, but it's really only necessary in library code.

It would be a shame of the lack of symbols is the only thing that kept
pre-es6-supporting libraries from using iterators or other code that uses
them.



> ______________________________**_________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/**listinfo/es-discuss<https://mail.mozilla.org/listinfo/es-discuss>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130625/4324d7f1/attachment-0001.html>


More information about the es-discuss mailing list