Fwd: [dojo-contributors] [feedback wanted] Preferred Iteration forms
bill at dojotoolkit.org
Mon Apr 3 18:35:34 EDT 2006
> On any of the Array based Collections, you can *always* call toArray and use the dojo.lang array functions to do functional iteration. In theory you can do the same with map-based collections by grabbing the KeyList from it and using dojo.lang.forEach for it.
> Why would I want to duplicate that functionality if you've already written it?
I think the issue is non-array based collections, such as graphs and
trees. Coercing those objects into arrays (copying all of the data) is
inefficient. Both calling dojo.lang.forEach() and imperative iterators
require copying all the data to an array. Thus writing your own
forEach() is better. (On the other hand, performance can always be done
later... but it's good to decide the API early)
> On Monday 03 April 2006 2:26 pm, Tom Trenka wrote:
>> Including the dojo.lang dependency will add 327 lines of code plus
>> the overhead of the dojo.require statements (if not used as part of a
>> build package). So adding dojo.lang.forEach may *seem* like a
>> convenience but it adds a bit of overhead.
It's hard to believe that many people are using dojo without including
lang/array.js. forEach() is referenced 38 times in the code, even from
More information about the dojo-contributors