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

2013-06-30 Thread Ron Buckton
From: Tab Atkins Jr.mailto:jackalm...@gmail.com Sent: ‎6/‎24/‎2013 1:28 PM To: Domenic Denicolamailto:dome...@domenicdenicola.com Cc: es-discussmailto:es-discuss@mozilla.org Subject: Re: Why does Array.from also take a mapFn? On Mon, Jun 24, 2013 at 12:55 PM, Domenic Denicola dome

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

2013-06-25 Thread Jason Orendorff
On Mon, Jun 24, 2013 at 12:01 PM, Rick Waldron waldron.r...@gmail.com wrote: Another question that I don't think got an answer, or if it did I was unable to understand it. Why is map singled out for `Array.from` instead of, say, filter? It seems arbitrary. It's not at all arbitrary: filter

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

2013-06-25 Thread Anne van Kesteren
On Tue, Jun 25, 2013 at 11:46 PM, Jason Orendorff jason.orendo...@gmail.com wrote: If (as I am beginning to suspect) it just makes no sense for NodeList to be a subclass of Array, we should urgently figure out some kind of recommendation for such cases. DOM has more than just the one. We could

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

2013-06-25 Thread Jason Orendorff
On Tue, Jun 25, 2013 at 9:46 AM, Jason Orendorff jason.orendo...@gmail.com wrote: Oh, I didn't get that Array.prototype.filter and the rest are going to be subclass-friendly! Hmm. I want to love this change, but I'm ambivalent. Typed arrays are fixed-length, and DOM NodeLists aren't even

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

2013-06-25 Thread Allen Wirfs-Brock
On Jun 25, 2013, at 7:46 AM, Jason Orendorff wrote: On Mon, Jun 24, 2013 at 12:01 PM, Rick Waldron waldron.r...@gmail.com wrote: Another question that I don't think got an answer, or if it did I was unable to understand it. Why is map singled out for `Array.from` instead of, say, filter? It

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

2013-06-25 Thread Hudson, Rick
, June 24, 2013 3:50 PM To: Domenic Denicola Cc: es-discuss Subject: Re: Why does Array.from also take a mapFn? First, you normally want map and other iterative array functions to return the same type of collect it was applied to: var smalls = Int8Array.of(34, 78, -150, 127, -3, 12); var

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

2013-06-25 Thread Rick Waldron
-discuss Subject: Re: Why does Array.from also take a mapFn? First, you normally want map and other iterative array functions to return the same type of collect it was applied to: var smalls = Int8Array.of(34, 78, -150, 127, -3, 12); var negatedSmalls = smalls.map(v= -v); //negatedSmalltalk

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 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 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.

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: 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