[fpc-devel] for-in-index loop

Alexander Klenin klenin at gmail.com
Fri Jan 25 00:31:40 CET 2013


On Fri, Jan 25, 2013 at 10:13 AM, Graeme Geldenhuys
<graeme at geldenhuys.co.uk> wrote:
> On 01/24/13 19:36, Alexander Klenin wrote:
>>> Enumerators are not iterators.
>> Eh... actually, they are? Why do you think otherwise?
>
> Enumerators are limited in functionality. Iterators are the full-blown
> thing. Common Iterator API is something like Next, Prev, Reset, HasNext,
> HasPrev etc. Enumerators normally just advance and only in one
> direction.  This is how it is in many frameworks. Even Java's
> documentation describes it like that - see the bottom of the page for
> Iterator.
> http://docs.oracle.com/javase/6/docs/technotes/guides/collections/reference.html
>

I see. However, I also see:
http://docs.oracle.com/javase/6/docs/api/java/util/Enumeration.html
"New implementations should consider using Iterator in preference to
Enumeration."
So in Java, "enumerator" is basically just a deprecated term for older
and weaker version of "iterator".

In the case of Pascal, I would rather say that enumerators are
iterators implementing a special interface,
which allow them to be used with a specific syntax.

--
Alexander S. Klenin



More information about the fpc-devel mailing list