Why does Array.from also take a mapFn?

2013-06-24 Thread Jason Orendorff
According to the January 30 meeting notes, Array.from is getting optional map functionality.[1] This is motivated by the following example: class V extends Array { constructor(...args) { super(...args); } } var v, m; v = new V(1, 2, 3); m =

Why does Array.from accept non-iterable arraylikes?

2013-06-24 Thread Jason Orendorff
According to [1], Array.from will first try treating the argument as an iterable, then as an arraylike. This is much better than just arraylike. The committee considered making it iterable only, but decided against it. The rationale recorded in the notes is: RW: No. Rick, can you expand on

Re: Why does Array.from accept non-iterable arraylikes?

2013-06-24 Thread Erik Arvidsson
I'm with Jason here. The only argument I can vaguely remember is that people want to be able to use these on old browsers without @@iterator? But I don't see why a polyfill could not tag things with __iterator__ or something else? On Mon, Jun 24, 2013 at 11:54 AM, Jason Orendorff

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Allen Wirfs-Brock
On Jun 24, 2013, at 8:42 AM, Jason Orendorff wrote: According to the January 30 meeting notes, Array.from is getting optional map functionality.[1] This is motivated by the following example: class V extends Array { constructor(...args) { super(...args); }

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Brandon Benvie
For reference, this is the thread: https://mail.mozilla.org/pipermail/es-discuss/2013-February/028661.html On 6/24/2013 9:31 AM, Allen Wirfs-Brock wrote: On Jun 24, 2013, at 8:42 AM, Jason Orendorff wrote: According to the January 30 meeting notes, Array.from is getting optional map

Re: Why does Array.from accept non-iterable arraylikes?

2013-06-24 Thread Allen Wirfs-Brock
On Jun 24, 2013, at 9:07 AM, Erik Arvidsson wrote: I'm with Jason here. The only argument I can vaguely remember is that people want to be able to use these on old browsers without @@iterator? But I don't see why a polyfill could not tag things with __iterator__ or something else? I

RE: Why does Array.from also take a mapFn?

2013-06-24 Thread Domenic Denicola
From: Allen Wirfs-Brock [al...@wirfs-brock.com] My recollection is that we first discussed that the existence of Array.from make this issue somewhat less important because, just as you point out, .from can be used in conjunction with anything that produces an Iterable such as

Re: Why does Array.from accept non-iterable arraylikes?

2013-06-24 Thread Rick Waldron
On Mon, Jun 24, 2013 at 11:54 AM, Jason Orendorff jason.orendo...@gmail.com wrote: According to [1], Array.from will first try treating the argument as an iterable, then as an arraylike. This is much better than just arraylike. The committee considered making it iterable only, but decided

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Brandon Benvie
On 6/24/2013 9:42 AM, Domenic Denicola wrote: That led to further discision of that usage and we got into things like the last example: ```js // Turn an array of nodeNames into NodeList of nodes NodeList.from( [div], node = document.createElement(node) ); ``` I think I must be missing

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Brandon Benvie
On 6/24/2013 9:44 AM, Brandon Benvie wrote: On 6/24/2013 9:42 AM, Domenic Denicola wrote: That led to further discision of that usage and we got into things like the last example: ```js // Turn an array of nodeNames into NodeList of nodes NodeList.from( [div], node =

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Allen Wirfs-Brock
On Jun 24, 2013, at 9:42 AM, Domenic Denicola wrote: From: Allen Wirfs-Brock [al...@wirfs-brock.com] My recollection is that we first discussed that the existence of Array.from make this issue somewhat less important because, just as you point out, .from can be used in conjunction with

RE: Why does Array.from also take a mapFn?

2013-06-24 Thread Domenic Denicola
From: Rick Waldron [waldron.r...@gmail.com] One reason is the extra allocation... It's not at all arbitrary: filter isn't an operation used to change the value of the items in the returned iterable. OK, I think I see. This is because `NodeList.prototype.map` behaves differently from

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Allen Wirfs-Brock
On Jun 24, 2013, at 10:22 AM, Domenic Denicola wrote: From: Rick Waldron [waldron.r...@gmail.com] One reason is the extra allocation... It's not at all arbitrary: filter isn't an operation used to change the value of the items in the returned iterable. OK, I think I see. This is

RE: Why does Array.from also take a mapFn?

2013-06-24 Thread Domenic Denicola
Thanks Allen. The ```js var squaredSmalls_try2= Int16Array.from(smalls.map(v= v*v)); // still no good, because intermediate array is Int8Array ``` example certainly clears it up for me. Tricky stuff. I was going to write it's still a bit weird to me that we overload `Array.from` with

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Tab Atkins Jr.
On Mon, Jun 24, 2013 at 12:55 PM, Domenic Denicola dome...@domenicdenicola.com wrote: Thanks Allen. The ```js var squaredSmalls_try2= Int16Array.from(smalls.map(v= v*v)); // still no good, because intermediate array is Int8Array ``` example certainly clears it up for me. Tricky stuff.

Function declarations with lexical `this`?

2013-06-24 Thread Axel Rauschmayer
Sorry for bringing this point up, again. It is a minor point, but details matter if ECMAScript 6 is supposed to feel consistent. In general, I like how ECMAScript 6 has evolved functions. Before, functions played three roles: 1. Constructor 2. Method 3. Non-method function (where you want

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Dmitry Soshnikov
On Mon, Jun 24, 2013 at 9:31 AM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: On Jun 24, 2013, at 8:42 AM, Jason Orendorff wrote: According to the January 30 meeting notes, Array.from is getting optional map functionality.[1] This is motivated by the following example: class V

Re: Function declarations with lexical `this`?

2013-06-24 Thread Dmitry Soshnikov
On Mon, Jun 24, 2013 at 5:00 PM, Mark S. Miller erig...@google.com wrote: On Mon, Jun 24, 2013 at 4:46 PM, Axel Rauschmayer a...@rauschma.dewrote: Sorry for bringing this point up, again. It is a minor point, but details matter if ECMAScript 6 is supposed to feel consistent. In general, I

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Allen Wirfs-Brock
On Jun 24, 2013, at 5:21 PM, Dmitry Soshnikov wrote: On Mon, Jun 24, 2013 at 9:31 AM, Allen Wirfs-Brock al...@wirfs-brock.com wrote: On Jun 24, 2013, at 8:42 AM, Jason Orendorff wrote: According to the January 30 meeting notes, Array.from is getting optional map functionality.[1]

Re: Why does Array.from also take a mapFn?

2013-06-24 Thread Dmitry Soshnikov
On Mon, Jun 24, 2013 at 5:45 PM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: On Jun 24, 2013, at 5:21 PM, Dmitry Soshnikov wrote: On Mon, Jun 24, 2013 at 9:31 AM, Allen Wirfs-Brock al...@wirfs-brock.comwrote: On Jun 24, 2013, at 8:42 AM, Jason Orendorff wrote: According to the