[fpc-devel] New feature discussion: for-in loop

Alexander Klenin klenin at gmail.com
Sun Oct 25 09:36:56 CET 2009


On Sun, Oct 25, 2009 at 16:49, Paul Ishenin <webpirat at mail.ru> wrote:
>> When I use
>> iterators, I would like to have the ability to use Current, HasNext,
>> HasPrevious, PeakNext, PeakPrevious, Reset, JumpToBack, pass a filter
>> to GetIterator... etc.
>
> I don't argue but how do you think to use HasPrevious, PeakNext,
> PeakPrevios, Reset, JumpToBack in the for-in loop? Can you suggest a syntax?

IMHO, Reset/JumpToBack should not be used inside "for..in" loop -- they are
analogous to "goto" inside for loop.
If "for .. in .. index" extension is implemented, it may be used to call
HasPrevious, PeakNext, PeakPrevious and other functions that do not
change iterator position.

>> Also, I referred to them in my implementation as Iterators - as per
>> the Iterator design pattern. How does Enumerator differ from Iterator?

It does not. I dislike the "Enumerator" term too, but this is how it
is called in Delphi :-(

-- 
Alexander S. Klenin



More information about the fpc-devel mailing list