Iterators recap

Bill Baxter dnewsgroup at billbaxter.com
Fri Dec 15 01:04:13 PST 2006


Sean Kelly wrote:
> Bill Baxter wrote:
>> Sean Kelly wrote:
>>> Bill Baxter wrote:
>>>>
>>>> Too bad the iterator discussions fizzled out without anything 
>>>> getting decided.
>>>
>>> I think the design was pretty well settled when things ended.  The 
>>> next step would be a sample implementation so folks could wrangle 
>>> over syntax.  It's on my "to do" list, but I'm a bit short on free 
>>> time at the moment.
>>
>> Huh.  So what is your understanding of what the consensus was?
> 
> Java-style, with random access iterators overloading array operations. I 
> can't remember if there was any clear preference for the hasNext/getNext 
> vs. the atEnd/getVal approach, but I tend to favor the latter.

I like next/value/(ptr) myself.
Makes for very succinct while loops.  ptr available where it makes sense.

while(iter.next()) {  writefln(iter.value); }

while(iter.next()) {  *iter.ptr = 17; }


--bb


More information about the Digitalmars-d-learn mailing list