Iterators for D

Bill Baxter dnewsgroup at billbaxter.com
Tue Nov 7 17:10:57 PST 2006


Chris Nicholson-Sauls wrote:
> Knud Sørensen wrote:
>> On Mon, 06 Nov 2006 12:46:01 -0800, Walter Bright wrote:
>>
>>
>>> It's becoming increasingly obvious that D needs iterators. While 
>>> opApply  is far better for some kinds of iteration (such as 
>>> recursively traversing a directory), iterators are more efficient in 
>>> some cases, and allow for things that opApply makes difficult.
>>>
>>
>>
>> What are those cases ? Maybe we can find a way to fix the problem with
>> opApply.
>>
> 
> Mostly agreed.  For example, one case I seem to find mentioned a few 
> times is providing depth-first versus breadth-first iteration on a tree 
> -- supposedly this is hard to do with foreach/opApply.  

Other way around.  Tree traversal is harder to do with C++ style 
iterators, easy to do with opApply.  I assume your code is correct but 
didn't look at it too closely.

--bb



More information about the Digitalmars-d mailing list