On Tue, Jan 3, 2012 at 10:16 AM, Mariusz Nowak < medikoo+mozilla....@medikoo.com> wrote:
> > > Rick Waldron wrote: > > > > On Tue, Jan 3, 2012 at 9:19 AM, Mariusz Nowak < > > medikoo+mozilla....@medikoo.com> wrote: > > > >> > >> > >> Rick Waldron wrote: > >> > > >> > On Tue, Jan 3, 2012 at 3:34 AM, Mariusz Nowak < > >> > medikoo+mozilla....@medikoo.com> wrote: > >> > > >> >> > >> >> > >> >> Rick Waldron wrote: > >> >> > > >> >> > On Mon, Jan 2, 2012 at 3:56 PM, Mariusz Nowak < > >> >> > medikoo+mozilla....@medikoo.com> wrote: > >> >> > > >> >> >> > >> >> >> I like it, it indeed looks very logical, however it's a bit > >> >> controversial > >> >> >> that we need to create temporary array object to get one that we > >> want. > >> >> >> > >> >> > > >> >> > Is the controversy editorial or fact, because the following methods > >> are > >> >> > all > >> >> > specified to use a temporary, newly initialized Array internally: > >> >> > > >> >> > Array.prototype.concat > >> >> > Array.prototype.filter (...) > >> >> > > >> >> > >> >> Rick, you say that apart of output arrays this methods create some > >> other > >> >> temporary arrays internally ? > >> >> I don't see anything like that in specification, where exactly is it > >> >> stated > >> >> ? > >> >> > >> > > >> > > >> > Array.prototype.concat > >> > - http://es5.github.com/#x15.4.4.4 #2 > >> > > >> > Array.prototype.filter > >> > - http://es5.github.com/#x15.4.4.20 #6 > >> > > >> > (...) > >> > > >> > >> Rick, those arrays become result of each method, they're not temporary. > >> > > > > Sorry, I should've been clearer... I was responding to your statement > that > > implied Axel's example code was somehow creating an unnecessary temporary > > array - have I missed something here? > > > > > > Rick, what I meant is that it implies creation of temporary array object. > Let's say I want to have an array made of numbers 1,2,3 repeated three > times. To get it I need to create temporary [1, 2, 3] array which I don't > really need: > result = [1, 2, 3].repeat(3); > > It'll be more clean if it will work directly on context array: > > var x = [1, 2, 3]; > x.repeat(2); > console.log(x); // [1, 2, 3, 1, 2, 3]; > > but that probably won't be expected behavior by most developers. > Thanks for clarifying - I had been under the impression that you were referring to the implementation details specifically. > > Anyway as Greg pointed, it's hard to find a valid use case for any array > repeating method, it conceptually may look as nice add-on, but I'm not sure > if it would be that useful to have it in standard. > +1 > > -- > Mariusz Nowak > https://github.com/medikoo/ > > ----- > Mariusz Nowak > > https://github.com/medikoo > -- > View this message in context: > http://old.nabble.com/Suggestion%3A-Array.prototype.repeat-tp33067649p33072532.html > Sent from the Mozilla - ECMAScript 4 discussion mailing list archive at > Nabble.com. > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss