Hudson, Rick (2013-12-06T22:17:49.000Z)
Agreed, index is the index of the destination where the value returned from the closure parameter will be placed. This is the right way to think about index. Using it directly on the source is at best redundant since element === collection[index]. The fact that the destination isn't available yet doesn't make the destination index useless. One use case that comes to mind is a convolution like a blur function in image processing. The index indicates the location in the destination where the newly created value is to be placed.

	- Rick

-----Original Message-----
From: Allen Wirfs-Brock [mailto:allen at wirfs-brock.com] 
Sent: Friday, December 06, 2013 4:07 PM
To: Hudson, Rick
Cc: Niko Matsakis; es-discuss at mozilla.org
Subject: Re: Aligning from() and map()


On Dec 6, 2013, at 12:18 PM, Hudson, Rick wrote:

> Allen> 1)  For the map method, the source and destination collection are the same object so the collection argument to the closure parameter identifiers both the source and destination object
> 
> Not sure I'm following you here. The collection passed to the closure parameter (aka callback function) in map is the source and not the destination. As far as I can tell the destination isn't available until map returns it.

Right, sorry first post of the morning.  Coffee wasn't active yet.

There is still a difference.  With map, the source collection is the this value of the map method and has implementation level visibility of the source collection.  The map method is specified to do explicit index iteration over the indices of the source collection.   With the from method, the source may simply be an Iterable Iterator (an Iterator with a @@iterator method). The ultimate source of the data isn't necessarily known to the from method and since index-based iteration isn't used to access the iterator, any index passed to the closure would be a destination index.  But, as you point out, the destination object isn't available to the closure. 

Allen
forbes at lindesay.co.uk (2013-12-07T18:01:54.353Z)
Agreed, index is the index of the destination where the value returned from the closure parameter will be placed. This is the right way to think about index. Using it directly on the source is at best redundant since element === collection[index]. The fact that the destination isn't available yet doesn't make the destination index useless. One use case that comes to mind is a convolution like a blur function in image processing. The index indicates the location in the destination where the newly created value is to be placed.