Standard @iter module unfriendly to collection builders
brendan at mozilla.com
Mon Nov 14 12:01:14 PST 2011
On Nov 14, 2011, at 11:59 AM, Erik Arvidsson wrote:
> On Mon, Nov 14, 2011 at 09:07, Allen Wirfs-Brock <allen at wirfs-brock.com> wrote:
>> Another possibility would be to build in default @iterator methods on
>> Object.prototype and Array.prototype. I'd probably make the object
>> implementation be an items for enumerable properties and the array
>> implementation iterate the values of 0..length-1 .
> Defining @iterator on Object.prototype seems like it would be a
> disservice to future js programmers. It would basically turn the
> for-of loop into another reflection based loop and we would be back to
> square one.
> I'm in favor of Array.prototype. at iterator though
Yes, good point! I forgot to say that in my last reply. That seems unproblematic since anything delegating to Array.prototype should be array-like in wanting for-of to iterate values in index order, skipping holes.
More information about the es-discuss