foreach, an analogy
clayasaurus
clayasaurus at gmail.com
Thu Oct 19 14:30:40 PDT 2006
Bill Baxter wrote:
> ... long analogy
Here is my view on foreach_reverse
1) I really like the idea of foreach being the defacto-iterator for D
2) foreach_reverse allows me to implement an opApply function to my
doubly linked list template for not only forward iteration, but
backwards iteration as well! Otherwise, I'd have to pass it a
&list.reverse delegate which is hackish.
Although I wonder if one could just pass in an extra parameter in the
opApply function to specify forward, reverse, unordered, ordered. like...
foreach(int b; array; "reverse")
foreach(int b; array); // assume forward, or whatever the default is
foreach(int b; array; "ordered")
foreach(int b; array; "unordered")
I like the functionality of foreach_reverse, I just think there might be
a more flexible way to implement, and in a way so that it makes sense to
anyone who understands the D language. (I'm not saying that
foreach_reverse is not understandable, I'm just not very excited about
allowing the programmer to program their own flow control loop
statements like forever {} ).
More information about the Digitalmars-d-announce
mailing list