Re: controlling sparseness of Array iterators (was: Array#filter without callback function)

2012-11-12 Thread Andrea Giammarchi
this is really easy to fix via code but I would rather propose an Array#compact() or Array#dense() method rather than changing everything else (included shims/polyfills) I really don't remember when it happened last time that I had to deal with such kind of Arrays ... and this made already every p

Re: controlling sparseness of Array iterators (was: Array#filter without callback function)

2012-11-12 Thread Jason Orendorff
On Mon, Nov 12, 2012 at 4:39 PM, Allen Wirfs-Brock wrote: > So the question on the floor: is there any interest in having this > variation of array iteration in ES6? > No. Why complicate the API with a feature just for people who use sparse arrays on purpose? From what we hear, there are almost

Re: controlling sparseness of Array iterators (was: Array#filter without callback function)

2012-11-12 Thread Allen Wirfs-Brock
On Nov 12, 2012, at 3:03 PM, Erik Arvidsson wrote: > On Mon, Nov 12, 2012 at 5:39 PM, Allen Wirfs-Brock > wrote: > So the question on the floor: is there any interest in having this variation > of array iteration in ES6? > > I would prefer not. Sparse arrays are really rare and for the few c

Re: controlling sparseness of Array iterators (was: Array#filter without callback function)

2012-11-12 Thread Erik Arvidsson
On Mon, Nov 12, 2012 at 5:39 PM, Allen Wirfs-Brock wrote: > So the question on the floor: is there any interest in having this > variation of array iteration in ES6? > I would prefer not. Sparse arrays are really rare and for the few cases these are used I expect the author to be willing to pay

controlling sparseness of Array iterators (was: Array#filter without callback function)

2012-11-12 Thread Allen Wirfs-Brock
In the Oct. ES6 draft you may noticed that there is an editor's comment attached to each of sections 15.4.4.23-25. These are the definitions of the items, keys, and values methods on array objects. The note says:"Need to decide whether to allow an argument that requests sparse iteration". In

Re: Array#filter without callback function

2012-11-12 Thread Andrea Giammarchi
Asen, as mentioned what I meant is that I would sparse.filter(Object); once if that's about having a repeated iteration. This let you avoid the Boolean.bind(null, true) if that was the concern but I have no idea about performances. There are too many libraries to change in order to support this d

Re: Array#filter without callback function

2012-11-12 Thread Andrea Giammarchi
if it's about iterating you have forEach which does not iterate over non assigned indexes ... this looks like you want a new feature with an ES5 method as filter is so that you can use an ES3 for loop after ... I mean, you have forEach, map, etc to iterate valid indexes, why would you need that?

Array#filter without callback function

2012-11-12 Thread Asen Bozhilov
Hi, Array.prototype.filter could be used to convert sparse to dense array, e.g. [1,2,3].filter(Boolean.bind(null, true)); //[1, 2, 3] Would be pretty straightforward if built-in filter could be called without callback function and returns a dense array. I guess the engines will optimize