
On 13/10/10 00:15, David Sankel wrote:
Please please please, if you're going to attempt a better alternative for iterators, read "The essence of the Iterator pattern" [1] (or [2] for an updated version) and the important work on idioms[3] that it references. I wish I had more time to spend on this effort, but needless to say the tough semantic work has already been done!
Thanks David A. for pointing out there was a semantics discussion going on here.
David
[1] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.103.7480 [2] http://www.comlab.ox.ac.uk/jeremy.gibbons/publications/iterator.pdf [3] http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.100.22
This is interesting in essence, but I fear it abstracts too much into lambda land. (to the point where I don't understand it, but that's another problem ;)) From a glimpse at your paper, the advantages of your approach over a monadic map (which is what I take to be the most similar thing to a fold in C++, since C++ has side effects) is that it allows composition, and doesn't need two symmetric definitions to traverse the data both ways. Is that correct? Unfortunately I do no understand how one would use this in C++. The approach seems a bit similar to continuations, unless I'm completely out of it? I have already suggested using coroutines to make the iteration more flexible, but it comes with a runtime cost (context switching).