The author of the experimental language Magpie is very
intelligent (in past I have read a very nice blog post about the
unusual bootstrapped type system of Magpie). Here he nicely
discusses well known things:
http://journal.stuffwithstuff.com/2013/01/13/iteration-inside-and-out/
Reddit thread:
http://www.reddit.com/r/programming/comments/16ja3f/iteration_inside_and_out/
A person on Reddit ("munificent", I think the blog post author
himself) says that Magpie uses fibers to solve that dilemma, to
be seen in a successive post.
In D the Range static protocol of iteration is external and
opApply is internal. Some persons have suggested to use fibers in
D to introduce a very handy "yield" syntax for internal iteration.
I think similarly short but clear article, about D Ranges and
opApply should be added in the articles
(http://dlang.org/articles.html ) section of the D site.
Bye,
bearophile