Allen Wirfs-Brock (2013-12-06T21:20:20.000Z)
domenic at domenicdenicola.com (2013-12-10T01:39:02.720Z)
On Dec 6, 2013, at 1:00 PM, Niko Matsakis wrote: > How are the source and destination collection the same in the case of > map()? Perhaps you meant that they are the same *type of collection*? No, I just wasn't fully awake yet... > This is true, but I'm not sure how important it is. Just define the > index to be the number of items traversed thus far. If users move > `from` to other types for which a numeric index is inappropriate > (e.g., `set`), so be it. But aren't we now back to your parallelism problem. It would seem that the only index/count like value that is order and Iterator protocol independent is the destination index. > Yes, a parallel version of from can only be used with collections that > support indexing. Note as currently specified, the from methods prefer Iterator protocol over indexing for when presented with a source collection that supports both. > I don't personally think the *collection* argument is especially > useful. You can always capture it in the closure if you like. > I only included the collection argument for consistency with map. > > The *index* however is clearly useful. Most every generic iteration > facility I've seen includes an adapter like Python's enumerate() or > Scala's zipWithIndices() precisely because having access to the index > is a handy thing. As examples, consider a function that wants to > access the neighbors of the current element. Yes, but in the interator source scenario indexed access to the source collection may not be available. > Furthermore, I just think people will find it surprising that from/map > don't operate as analogously as possible (I certainly did). Does the surprise then lead you to deeper understanding of essential differences? Essentially what we are discussing is whether or not they actually already are as close as possible,